Fix ion_sound_speed ignoring provided average ionization (Z) parameter#3217
Fix ion_sound_speed ignoring provided average ionization (Z) parameter#3217yaochengchen wants to merge 3 commits intoPlasmaPy:mainfrom
Conversation
…ulation. Add Yaocheng Chen to CITATION.cff
|
Thank you for submitting this pull request (PR)! ✨ Below are checks that are being run for this PR. Click on the name of a check to learn why it didn't pass. ✅ Don't worry if something broke! We break stuff all the time. 😅 PlasmaPy's contributor guide has pages on:
Tip 📚 For a documentation preview, click on docs/readthedocs.org:plasmapy below. For cryptic documentation errors, see the documentation troubleshooting guide. Tip 🧹 Automatically fix most pre-commit.ci failures by commenting We thank you once again! 🌌 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3217 +/- ##
=======================================
Coverage 94.59% 94.59%
=======================================
Files 108 108
Lines 9872 9873 +1
Branches 1501 1501
=======================================
+ Hits 9338 9339 +1
Misses 332 332
Partials 202 202 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thank you for submitting this! In this case, In >>> from plasmapy.particles import particle_input, ParticleLike, Particle
>>>
>>> @particle_input
... def transform_into_particle(particle: ParticleLike, Z=None) -> Particle:
... return particle
...
>>> transform_into_particle("He", Z=2)
Particle("He 2+")This pattern is less explicit, but decorators help us avoid having to repeat code that used in a lot of different functions. |
Thanks @namurphy for the clarification — that makes sense now. I really appreciate this design pattern; it's a clean way to avoid repeating logic across functions. Thanks for the review, and sorry for the unnecessary trouble! |
Summary
This PR fixes a logic bug in
plasmapy.formulary.speeds.ion_sound_speedwhere the optional
Zparameter (intended to represent the averageionization of a plasma) was silently ignored in the sound speed
calculation.
Previously, the implementation always used
ion.charge_numberin the formula: