Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix aggregate_channels merging of channel ids with different string sub type #3740

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

h-mayorquin
Copy link
Collaborator

This will fix @chrishalcrow bug on #3733.

The current check for all_channels_have_same_type is too strict. I added a test.

@h-mayorquin h-mayorquin added the bug Something isn't working label Mar 4, 2025
@h-mayorquin h-mayorquin self-assigned this Mar 4, 2025
@h-mayorquin
Copy link
Collaborator Author

The error comes from the token limit : P

chan_id in parents_chan_ids for chan_id in self._channel_ids
), "ChannelSliceRecording : channel ids are not all in parents"
is_channel_in_parent = [chan_id in parents_chan_ids.tolist() for chan_id in self._channel_ids.tolist()]
assert all(is_channel_in_parent), "ChannelSliceRecording : channel ids are not all in parents"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be helpful to list them? Something like

channels_not_in_parents = [chan_id for chan_id in self._challen_ids.tolist() if chan_id not in parents_chan_ids.tolist()]
assert len(channels_not_in_parents) == 0, f"ChannelSliceRecording : channel ids {channels_not_in_parents} are not all in parent ids {parents_chan_ids}"

Or maybe this is totally overwhelming for large dense probes?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to add the channel list in the error message

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. I will add in the next commit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -118,5 +118,19 @@ def test_channel_aggregation_does_not_preserve_ids_not_the_same_type():
assert list(aggregated_recording.get_channel_ids()) == ["0", "1", "2", "3", "4"]


def test_channel_aggregation_with_string_dtypes_of_different_size():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely test!
Would be nice to have a docstring with a brief description.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a docstring. Let me know what you think.

@chrishalcrow
Copy link
Collaborator

Works for me, and looks less hacky than my proposed solution. Just made some doc-y comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants