Repository navigation
Conversation
SpectralTimeEventModel.get_group's docstring promises that a None for
event_inds or window_inds selects all available indices along that axis.
For output_type='event', the data and event_group_results were already
indexed with the checked/converted einds and winds, but event_time_results
was indexed with the raw event_inds/window_inds parameters instead:
event_time_results[key][event_inds][:, window_inds]
numpy treats None as np.newaxis when used as an index, not "select all",
so passing None on one axis inserted a spurious extra axis into every
event_time_results array, and the whole population step was additionally
skipped outright when both were None, leaving event_time_results empty
and data.spectrograms unset despite the documented "selects all" contract.
Use the already-computed einds/winds (from check_inds, which does convert
None to a full-range selection) for event_time_results, and always run the
population step for output_type='event' rather than only when at least one
index argument is given. The output_type in ('time', 'group') branch is
unchanged: an existing test asserts that None there intentionally yields
an empty export.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
SpectralTimeEventModel.get_group's docstring promises:For
output_type='event', the data (spectrograms) andevent_group_resultswere correctly indexed witheinds/winds(the checked/converted indices fromcheck_inds, which turnsNoneinto a full-range selection). Butevent_time_resultswas indexed with the rawevent_inds/window_indsparameters instead:numpy treats
Noneasnp.newaxiswhen used as an index, not "select all". So:Nonefor just one ofevent_inds/window_indsinserted a spurious extra axis into everyevent_time_resultsarray (e.g. shape(2, 1, 3)instead of(2, 3)).if event_inds is not None or window_inds is not None:, so passingNonefor both skipped it entirely, leavingevent_time_resultsempty anddata.spectrogramsunset, rather than the documented "select all" result.Repro
Fix
Use the already-computed
einds/windsforevent_time_results, and always run the population step foroutput_type='event'instead of only when at least one index argument is given, matching the "None selects all" contract.The
output_type in ('time', 'group')branch is intentionally left untouched —test_event_get_groupalready asserts thatNonethere yields an empty export (a different, deliberate contract for the export path), so I kept that behavior as-is.Testing
Extended
test_event_get_groupto check thatget_group(None, None)returns the full data/results shapes, and that givingNoneon only one axis (get_group([0], None)) doesn't insert a spurious axis. Confirmed the new assertions fail on the pre-fix code (AttributeError: 'NoneType' object has no attribute 'shape'for the both-None case) and pass after the fix. Full suite: 375 passed, 9 skipped (same skip count as the unmodified checkout).