-
Notifications
You must be signed in to change notification settings - Fork 3
Refactor MagneticMultipoleParameters
#44
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
Refactor MagneticMultipoleParameters
#44
Conversation
- remove code duplication and hard-coded string accesses - more detailed error messages - add support for `Kn` and `Ks` and length-integrated `...L` parameters
| def validate(cls, values: Dict[str, Any]) -> Dict[str, Any]: | ||
| # loop over all attributes | ||
| @classmethod | ||
| def validate(cls, values: dict[str, Any]) -> dict[str, Any]: |
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.
What is the difference between using dict and Dict (from typing) and why is it better to use dict here?
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.
dict is a Python intrinsic and needs no import. Thus, better.
Better generally is:
- intrinsic of the language
- stdlib package (typing, etc.)
- pydantic
In terms of compatibility (i.e., more tools understand intrinsics than stdlib than 3rd part libs) and performance (e.g., less imports is better).
|
Note that everywhere we say "must be a positive integer (>=0)..." or "must be a valid positive integer (>=0)", but I think this is typically referred to as a "non-negative integer", given that 0 isn't positive. I would personally rephrase all instances with "must be a non-negative integer". |
|
Yeah, I replaced In essence, I tried to avoid a double negative for readability :) |
Co-authored-by: Edoardo Zoni <ezoni@lbl.gov>
In preparation of #38, refactor
MagneticMultipoleParameters.KnandKsand length-integrated...Lparameters