Skip to content

Conversation

@MGAMZ
Copy link
Contributor

@MGAMZ MGAMZ commented Oct 21, 2025

When using SortingAnalyzer and compute, if user specifies too many args, there will be an assertion error. But the assertion message does not contain the detailed message about which arg violates the API.

So I wish to improve the assertion message. The modification is simple and straightforward, should not introduce any logical breaking.

Copilot AI review requested due to automatic review settings October 21, 2025 01:04
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves error messages in the SortingAnalyzer.compute() method by adding detail about which invalid arguments were passed when too many arguments are provided.

Key Changes:

  • Enhanced assertion error messages to include the list of unexpected parameter keys when users pass invalid arguments to compute_several_extensions()

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 1637 to 1638
assert len(params_) == 0, ("Too many arguments for SortingAnalyzer.compute_several_extensions(), "
f"they are: {list(params_.keys())}")
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

The conversion list(params_.keys()) is redundant. Dictionary keys can be directly used in f-strings, which will display them in a more readable dict_keys format. Consider using f'they are: {params_.keys()}' or if a list format is preferred, f'they are: {set(params_)}' for cleaner output.

Copilot uses AI. Check for mistakes.
params_, job_kwargs = split_job_kwargs(kwargs)
assert len(params_) == 0, "Too many arguments for SortingAnalyzer.compute_several_extensions()"
assert len(params_) == 0, ("Too many arguments for SortingAnalyzer.compute_several_extensions(), "
f"they are: {list(params_.keys())}")
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

The conversion list(params_.keys()) is redundant. Dictionary keys can be directly used in f-strings, which will display them in a more readable dict_keys format. Consider using f'they are: {params_.keys()}' or if a list format is preferred, f'they are: {set(params_)}' for cleaner output.

Suggested change
f"they are: {list(params_.keys())}")
f"they are: {set(params_)}")

Copilot uses AI. Check for mistakes.
@MGAMZ MGAMZ requested a review from Copilot October 21, 2025 02:16
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 1637 to 1639
assert len(params_) == 0, (
"Too many arguments for SortingAnalyzer.compute_several_extensions(), " f"they are: {set(params_)}"
)
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

The f-string prefix should be applied to the entire string, not just the second part. Move the 'f' prefix before the opening quote of the string or combine into a single f-string: f\"Too many arguments for SortingAnalyzer.compute_several_extensions(), they are: {set(params_)}\"

Copilot uses AI. Check for mistakes.
Comment on lines 1643 to 1645
assert len(params_) == 0, (
"Too many arguments for SortingAnalyzer.compute_several_extensions(), " f"they are: {set(params_)}"
)
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

The f-string prefix should be applied to the entire string, not just the second part. Move the 'f' prefix before the opening quote of the string or combine into a single f-string: f\"Too many arguments for SortingAnalyzer.compute_several_extensions(), they are: {set(params_)}\"

Copilot uses AI. Check for mistakes.
@MGAMZ
Copy link
Contributor Author

MGAMZ commented Oct 21, 2025

Copilot suggestions have been partially accepted, not accepting the second suggestion.

Now the code LGTM.

@alejoe91 alejoe91 added the core Changes to core module label Oct 21, 2025
@alejoe91 alejoe91 added this to the 0.103.1 milestone Oct 24, 2025
@chrishalcrow
Copy link
Member

Hey @MGAMZ, it would be great if the error message told the user what to do to fix the error. Maybe instead of "they are: ..." we could say something like "please remove the arguments {set(params_)} from the compute function.". What'dya think?

@MGAMZ
Copy link
Contributor Author

MGAMZ commented Oct 29, 2025

Hey @MGAMZ, it would be great if the error message told the user what to do to fix the error. Maybe instead of "they are: ..." we could say something like "please remove the arguments {set(params_)} from the compute function.". What'dya think?

That would be better~ Commit done.

Co-authored-by: Chris Halcrow <[email protected]>
@MGAMZ
Copy link
Contributor Author

MGAMZ commented Oct 29, 2025

@chrishalcrow My fault, missed another place. 😓

@alejoe91 alejoe91 merged commit 3642020 into SpikeInterface:main Oct 29, 2025
15 checks passed
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.

3 participants