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

ENH: Remove unused parameter from method prototype #134

Merged

Conversation

jhlegarreta
Copy link
Collaborator

@jhlegarreta jhlegarreta commented Mar 15, 2024

Remove unused parameter from method prototype: PET images do not have a b0 image. Use the *_ to denote unused arguments for the PET class and use a kwargs dictionary for the DWI case.

@jhlegarreta
Copy link
Collaborator Author

Not sure whether this was put intentionally to make the interface the same as for DWI but in that case a base class would be more appropriate, or to use kwargs.

@jhlegarreta jhlegarreta force-pushed the RemoveUnusedParamterFromPrototype branch from 2b2c49b to 4333659 Compare March 21, 2024 13:06
@oesteban
Copy link
Member

This is intentional, perhaps a bad way of defining an API, but all methods need to have that argument :)

How would you go about it?

@jhlegarreta
Copy link
Collaborator Author

My first thought is that it should not be there if it is not common to all classes :-S

Thoughts:

  • Could be a passed as kwargs and do insert_b0 = kwargs['insert_b0'] for the DWI case.
  • Other solutions:
    • Mark as # pylint: disable=unused-argument or # noqa: F841 (less preferable than the below)
    • Do _ = (insert_b0) as the first statement in the method in the PET case
    • Do del insert_b0 as the first statement in the method in the PET case
    • Declare the method as def to_nifti(self, filename, *_): in the PET case
    • Declare the method as def to_nifti(self, filename, *insert_b0): in the PET case

@oesteban
Copy link
Member

oesteban commented Mar 28, 2024

  • Do _ = (insert_b0) as the first statement in the method in the PET case

This argument is strong—why does PET have to have insert_b0 in the first place? Your solution of using kwargs seems the right choice.

Thanks for point out this issue.

Remove unused parameter from method prototype: PET images do not have a
`b0` image. Use the `*_` to denote unused arguments for the `PET` class
and use a `kwargs` dictionary for the `DWI` case.
@jhlegarreta jhlegarreta force-pushed the RemoveUnusedParamterFromPrototype branch from 4333659 to 102a820 Compare March 28, 2024 13:36
@jhlegarreta
Copy link
Collaborator Author

Done in 102a820.

@oesteban oesteban merged commit 284aad8 into nipreps:main Mar 28, 2024
7 checks passed
@jhlegarreta jhlegarreta deleted the RemoveUnusedParamterFromPrototype branch March 28, 2024 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants