Skip to content

STYLE: Call itk.ParameterObject.GetDefaultParameterMap the static way#351

Merged
thewtex merged 1 commit intoInsightSoftwareConsortium:mainfrom
N-Dekker:Call-ParameterObject-static
Dec 8, 2025
Merged

STYLE: Call itk.ParameterObject.GetDefaultParameterMap the static way#351
thewtex merged 1 commit intoInsightSoftwareConsortium:mainfrom
N-Dekker:Call-ParameterObject-static

Conversation

@N-Dekker
Copy link
Collaborator

@N-Dekker N-Dekker commented Dec 4, 2025

In C++, GetDefaultParameterMap is a static member function of the ParameterObject class, and in Python, it does indeed have a @staticmethod decorator (looking at "site-packages\itk\elxParameterObjectPython.py"), so it can also be called "in the static way", without using an instance of ParameterObject.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@N-Dekker N-Dekker requested a review from thewtex December 4, 2025 17:56
@N-Dekker
Copy link
Collaborator Author

N-Dekker commented Dec 5, 2025

@dzenanz
Copy link
Member

dzenanz commented Dec 5, 2025

Agreed. Merge unless you want to wait for Matt's review.

@N-Dekker
Copy link
Collaborator Author

N-Dekker commented Dec 5, 2025

Agreed. Merge unless you want to wait for Matt's review.

Thanks, @dzenanz.

As a follow-up I'm considering to replace code like:

parameter_object = itk.ParameterObject.New()
parameter_map = parameter_object.GetDefaultParameterMap('rigid',3)
parameter_object.AddParameterMap(parameter_map)

with:

parameter_map = parameter_object.GetDefaultParameterMap('rigid',3)
parameter_object = itk.ParameterObject.New(parameter_map = parameter_map)

Or even

parameter_object = itk.ParameterObject.New(parameter_map = parameter_object.GetDefaultParameterMap('rigid',3))

Less is more 😺

@thewtex
Copy link
Member

thewtex commented Dec 5, 2025

thanks @N-Dekker !

parameter_map = parameter_object.GetDefaultParameterMap('rigid',3)
parameter_object = itk.ParameterObject.New(parameter_map = parameter_map)

I think this is the best combination of conciseness and readability.

Per standard Python style, parameter_map=parameter_map.

In C++, `GetDefaultParameterMap` is a static member function of the `ParameterObject` class, and in Python, it does indeed have a `@staticmethod` decorator (looking at  "site-packages\itk\elxParameterObjectPython.py"), so it can also be called "in the static way", without using an instance of `ParameterObject`.
@N-Dekker N-Dekker force-pushed the Call-ParameterObject-static branch from 31f9edd to 6d377a2 Compare December 7, 2025 13:18
@thewtex
Copy link
Member

thewtex commented Dec 8, 2025

CI failures seem unrelated.

@thewtex thewtex merged commit 7e4947c into InsightSoftwareConsortium:main Dec 8, 2025
18 of 20 checks passed
N-Dekker added a commit to N-Dekker/ITKElastix that referenced this pull request Mar 15, 2026
Follow-up to pull request InsightSoftwareConsortium#351 commit 6d377a2 "STYLE: Call `itk.ParameterObject.GetDefaultParameterMap` the static way"
N-Dekker added a commit to N-Dekker/ITKElastix that referenced this pull request Mar 15, 2026
Follow-up to pull request InsightSoftwareConsortium#351 commit 6d377a2 "STYLE: Call `itk.ParameterObject.GetDefaultParameterMap` the static way"
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.

3 participants