-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add convenience min, max properties to FieldMesh #80
Add convenience min, max properties to FieldMesh #80
Conversation
pmd_beamphysics/fields/fieldmesh.py
Outdated
dtheta = _create_delta_property("theta") | ||
|
||
# Maxs | ||
def _create_max_property(name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These property
-creating helper functions don't have to live in the class body, just so you know
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, changed.
return property(getter, setter) | ||
|
||
# Create max properties dynamically | ||
xmax = _create_max_property("x") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you're refactoring these, you might consider adding on a doc
for each attribute. That could help with future documentation efforts.
https://docs.python.org/3/library/functions.html#property
property(..., doc="...")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
pmd_beamphysics/fields/fieldmesh.py
Outdated
self.attrs["gridOriginOffset"] = tuple(mins) | ||
|
||
return property( | ||
getter, setter, doc=f"Mesh minimim in {name}. This can also be set." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getter, setter, doc=f"Mesh minimim in {name}. This can also be set." | |
getter, setter, doc=f"Mesh minimum in {name}. This can also be set." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
It also refactors some of the convenience methods in
FieldMesh
:FieldMesh.xmin
,FieldMesh.ymin
, etc.FieldMesh.xmax
,FieldMesh.ymax
, etc.