Skip to content

More informative errors in frame slicing #3933

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

Merged

Conversation

h-mayorquin
Copy link
Collaborator

This comes from here:

catalystneuro/neuroconv#1355

where a users has a slicing error and I don't have enough info to debug it.

@h-mayorquin h-mayorquin self-assigned this May 16, 2025
@h-mayorquin
Copy link
Collaborator Author

Oh, the rate limit.

@@ -40,9 +40,9 @@ def __init__(self, parent_recording, start_frame=None, end_frame=None):
else:
assert (
0 < end_frame <= parent_size
), f"'end_frame' must be fewer than number of samples in parent: {parent_size}"
), f"'{end_frame=}' must be fewer than number of samples in parent: {parent_size=}"
Copy link
Member

Choose a reason for hiding this comment

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

Does the user know what parent_size is? or is that an internal variable to represent the size of the parent. I'm wondering if this is better as {parent_size} instead. The rest looks good to me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If you think that's better I am OK with it. I think that parent size is a bad variable name overall.

Copy link
Member

Choose a reason for hiding this comment

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

It's a super minor point. I don't see the value of saying

>>> 
... samples in parent: parent_size=xx

instead of

>>> samples in parent: xx

But I agree parent size is not super clear to the end-user as a variable name, which is why I don't think we even show that variable name in the error.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed. Let me know what you think.

assert (
0 < end_frame <= parent_size
), f"'end_frame' must be fewer than number of samples in parent: {parent_size}"
samples_in_sliced_recording = parent_recording.get_num_samples(segment_index=0)
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure? When I first read this I thought it was referring to the new child sliced recording rather than the parent. "sliced" can semantically be either child or parent. To be clear you would have to say samples_in_the_recording_to_be_sliced, but that is even worse. what about number_samples_in_recording or samples_in_recording? Because the user will assume the current recording? or you could say samples_in_current_recording to more emphasize it is the current recording?

How were you understanding samples_in_sliced_recording?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

samples in recording is fine for me if you think that's clear.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed,

Copy link
Member

@zm711 zm711 left a comment

Choose a reason for hiding this comment

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

I'm good with this. Did you want @alejoe91 to take a look too?

@alejoe91 alejoe91 added the core Changes to core module label May 22, 2025
@samuelgarcia
Copy link
Member

Merci beaucoup mon ami.
Parafit pour moi.
@alejoe91 do you want to check ?

@alejoe91 alejoe91 merged commit 92a3d45 into SpikeInterface:main Jun 3, 2025
15 checks passed
@h-mayorquin h-mayorquin deleted the improve_frame_slicing_assertion branch June 3, 2025 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Changes to core module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants