Skip to content
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

Update classes & docs for ionization states and fix docstring formatting in plasmapy.particles #796

Merged
merged 105 commits into from Dec 15, 2020

Conversation

namurphy
Copy link
Member

@namurphy namurphy commented May 4, 2020

This pull request adds narrative documentation for IonizationState and IonizationStates and fixes some typos.

@namurphy namurphy added the plasmapy.particles Related to the plasmapy.particles subpackage label May 4, 2020
@namurphy
Copy link
Member Author

namurphy commented May 4, 2020

I'm also wondering if it would be better to use the name IonizationStates or IonizationStateCollection, as I've noticed the latter style to be used occasionally. The latter style also provides more of a distinction when compared to IonizationState.

@StanczakDominik
Copy link
Member

I agree with renaming them. Having it be one letter of a typo away seems like a bad idea, come to think of them.

There are still some problems with how IonicFraction is called that I
will need to debug.
The name `IonizationStates` was too close to `IonizationState`.  This
renaming is to make sure that there are meaningful distinctions
between variable names.  My usage is that ionization state (singular)
refers to a single element, whereas ionization states (plural) refers
to multiple elements.
@pep8speaks

This comment has been minimized.

@namurphy
Copy link
Member Author

namurphy commented May 5, 2020

I just renamed IonizationStates to IonizationStateCollection. I'm also changing the State namedtuple to the IonicFraction class (which gets used when iterating over an ionization state). The tests that are broken right now are because I'm in the middle of that change.

I'm using ionization state (singular) to describe the ionic fractions for a single element, whereas ionization states (plural) refers to ionic fractions for multiple elements.

@codecov
Copy link

codecov bot commented May 6, 2020

Codecov Report

Merging #796 (86ca4b9) into master (fc2a72c) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@      Coverage Diff      @@
##   master   #796   +/-   ##
=============================
=============================

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fc2a72c...e425617. Read the comment docs.

@StanczakDominik StanczakDominik self-requested a review May 6, 2020 04:13
Up until now, the IonizationState class has required the base particle
to be either an element or isotope.  However, there may be some cases
where we want to set the ionic fraction to be 100% of a particular
ion.  This pull request allows us to do things like
IonizationState("alpha"), in which case the base particle will be He-4
and the ionic fractions will be [0.0, 0.0, 1.0] (i.e., all He-4 atoms
are doubly charged).

Credit for the idea goes to:
Co-authored-by: Maurice Wilson <maurice.wilson@cfa.harvard.edu>
@namurphy namurphy marked this pull request as ready for review May 7, 2020 15:45
@namurphy
Copy link
Member Author

namurphy commented May 8, 2020

Following namurphy/PlasmaPy-NEI#1, I've started thinking that it would be worthwhile to rewrite the tests for IonizationState and IonizationStateCollection using pytest fixtures. I think that would end up being a lot cleaner than the class-based approach currently in use. So that I'm less likely to forget...

  • Make an issue about whatever it was that I just said

@namurphy namurphy changed the title Update classes and docs for representing ionization states Update classes & docs for ionization states and fix docstring formatting in plasmapy.particles Oct 24, 2020
@namurphy
Copy link
Member Author

This is one of my sticking points with how @particle_input works. isotopic_abundance does not use argument mass_numb anywhere in its definition; thus, it appears as an unused parameter. If I didn't know that @particle_input wrangles this specific parameter, I would just remove it all together. There is just too much implicitness here, versus explicitness.

Yeah...I'm getting reticent about having @particle_input interpret mass_numb and Z...primarily because mass_numb and Z don't show up in the lists of parameters, etc. I don't want to deal with that in this pull request though, since I've let in a lot of scope creep already, as I have a tendency to do...

@rocco8773
Copy link
Member

rocco8773 commented Oct 24, 2020

This is one of my sticking points with how @particle_input works. isotopic_abundance does not use argument mass_numb anywhere in its definition; thus, it appears as an unused parameter. If I didn't know that @particle_input wrangles this specific parameter, I would just remove it all together. There is just too much implicitness here, versus explicitness.

Yeah...I'm getting reticent about having @particle_input interpret mass_numb and Z...primarily because mass_numb and Z don't show up in the lists of parameters, etc. I don't want to deal with that in this pull request though, since I've let in a lot of scope creep already, as I have a tendency to do...

I agree with that! I was thinking we'd have the discussion when I address issue #912 (and/or #918). I just wanted to point it out here.

@namurphy
Copy link
Member Author

namurphy commented Dec 1, 2020

This is the issue I mentioned during the community meeting today, which would be really helpful to have merged by our 0.5.0 release. There are some breaking changes here, and having this merged will make it easier for me when I get back to working on the non-equilibrium ionization modeling affiliated package...hopefully in the second half of December. Thank you in advance!

Copy link
Member

@StanczakDominik StanczakDominik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, except for a few comments added below and https://github.com/PlasmaPy/PlasmaPy/pull/796/files?file-filters%5B%5D=.py#r541546319 (number density scaling factor argument name "n" is confusing)!

docs/particles/ionization_states.rst Outdated Show resolved Hide resolved
plasmapy/particles/ionization_state.py Outdated Show resolved Hide resolved
Comment on lines +86 to +91
except Exception as exc:
raise TypeError(
"Unable to ascertain equality between the following objects:\n"
f" {self}\n"
f" {other}"
) from exc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed with @rocco8773's previous review (github interface is once again messing up here) - this should probably just return False.

plasmapy/particles/ionization_state.py Outdated Show resolved Hide resolved
plasmapy/particles/ionization_state.py Outdated Show resolved Hide resolved
StanczakDominik and others added 9 commits December 12, 2020 11:25
Co-authored-by: Erik Everson <eteverson@gmail.com>
Before this, __eq__ raised an exception.  This change was suggested
in code review.
The original kwarg name, `n`, did not satisfactorily convey that this
was a number density scaling factor.  `n0` does this better.  If this
too is insufficiently clear, then a future possibility would be
`n_scale_fac`.
I also added the solar wind as an example use case in the narrative
documentation.
@namurphy
Copy link
Member Author

Ok! I think I finished implementing the changes from code review, so if it looks good to you, feel free to merge. Thanks!

@StanczakDominik StanczakDominik merged commit 47e76d0 into PlasmaPy:master Dec 15, 2020
Documentation Development automation moved this from In Progress | Review to Complete Dec 15, 2020
@namurphy namurphy deleted the ionization-state-fixes branch September 10, 2021 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs PlasmaPy Docs at http://docs.plasmapy.org plasmapy.particles Related to the plasmapy.particles subpackage
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants