[BUG] Inconsistent lengths of indices
and rank
does not raise an error
#158
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
A small but notable bug I just came across:
indices
andrank
should both have shape(2, n_cons)
, however if the number of connections differs, e.g.this does not immediately raise an error. Instead, the use of
zip
elsewhere in the code to iterate over the entries ofindices
andrank
for each connection means that only the results for the smallest number of connections (in the above example 1 of 2) would be processed.Example of where
zip
is used:mne-connectivity/mne_connectivity/spectral/epochs_multivariate.py
Lines 185 to 186 in 28c3895
Proposed fix
Simply adding a check in
_check_rank_input
that the number of connections inindices
andrank
match is enough to catch this early on:mne-connectivity/mne_connectivity/spectral/epochs_multivariate.py
Lines 51 to 56 in 28c3895
I have also updated the unit tests to reflect this change.
Sorry for letting this slip through!