-
Notifications
You must be signed in to change notification settings - Fork 30
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
Composition - UserDict subclassing #731
Conversation
I really like |
With this, certain methods like |
In addition to subclassing |
Can you add a quick test to make sure all the different indexing variations work the same? ( |
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.
Pylint warnings are unrelated, from the new 3.2.0 version
Changes the
Composition
class to subclassUserDict
, allowing for direct key-value access of nuclei by string (e.g.comp["he4"]
) or byNucleus
object (e.g.comp[Nucleus("he4")]
orcomp.X[Nucleus("he4")]
. This also allows for dictionary operations such asfor nuc, x in comp.items():
andlen(comp)
. Also addscomp.A
andcomp.Z
getters for dictionaries of the molar masses and charges.