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
Make common_isotopes
, known_isotopes
, and stable_isotopes
each return a ParticleList
#2559
Make common_isotopes
, known_isotopes
, and stable_isotopes
each return a ParticleList
#2559
Conversation
@@ -664,11 +664,11 @@ def common_isotopes_for_element( | |||
CommonIsotopes = [ | |||
isotope | |||
for isotope in isotopes | |||
if "abundance" in _isotopes.data_about_isotopes[isotope] | |||
if "abundance" in _isotopes.data_about_isotopes[isotope.isotope] |
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.
Particle.isotope
returns a string with the symbol of the isotope, which is expected by that dict
.
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.
I thought we didn't return dict objects?
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.
The dict here was a private one containing isotope data, so it wasn't part of our public API. I'd say that there are times when a dict is a good choice for a return value, and other times when it's worth creating something like a class or namedtuple. As with everything, there are tradeoffs!
isotopic_abundance_elements = ( | ||
atomic_number(atomic_numb) for atomic_numb in range(1, 119) | ||
) |
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.
I seem to have discovered Python generators in Dec 2017 and perhaps maybe had just a little bit too much fun with them...
common_isotopes
, known_isotopes
, and stable_isotopes
return a ParticleList
common_isotopes
, known_isotopes
, and stable_isotopes
each return a ParticleList
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.
👍
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
Whilst working on #2458, I noticed that a few of the functions in
plasmapy.particles.atomic
each returned alist
containingParticle
objects. This PR changes it so that they return aParticleList
.