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 type hints and docstrings in plasmapy.formulary #2543

Merged
merged 10 commits into from Feb 28, 2024

Conversation

namurphy
Copy link
Member

@namurphy namurphy commented Feb 27, 2024

This PR adds and updates a bunch of type hint annotations in plasmapy.formulary. It also makes a few minor refactoring changes.

A limiting factor in doing this is that @validate_quantities is currently largely unannotated (#2435), but is being used to decorate a whole bunch of different functions. However, I'm going to leave that for another day (or more likely, another month).

@github-actions github-actions bot added plasmapy.formulary Related to the plasmapy.formulary subpackage testing plasmapy.formulary.quantum Related to the plasmapy.formulary.quantum module labels Feb 27, 2024
Copy link

codecov bot commented Feb 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.35%. Comparing base (20e60aa) to head (0721e4f).
Report is 43 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2543      +/-   ##
==========================================
+ Coverage   96.93%   97.35%   +0.42%     
==========================================
  Files         104      104              
  Lines        9163     9389     +226     
==========================================
+ Hits         8882     9141     +259     
+ Misses        281      248      -33     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -18,7 +18,7 @@
from plasmapy import particles
from plasmapy.formulary.collisions import coulomb, lengths, misc
from plasmapy.formulary.speeds import thermal_speed
from plasmapy.particles import ParticleLike
from plasmapy.particles.particle_class import ParticleLike
Copy link
Member Author

Choose a reason for hiding this comment

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

There was a mypy error about how plasmapy.particles doesn't explicitly export ParticleLike. Hence, I'm making a bunch of these import statements a lot more specific.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I remember this issue

Comment on lines -21 to +25
@particles.particle_input
@particle_input
def impact_parameter_perp(
T: u.Quantity[u.K],
species: (particles.Particle, particles.Particle),
species: (Particle, Particle),
Copy link
Member Author

Choose a reason for hiding this comment

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

To be more consistent with the import conventions we use elsewhere.

Copy link
Contributor

Choose a reason for hiding this comment

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

I love it when a review is just basically import statements, it makes the review a lot easier 😆

Copy link
Member Author

Choose a reason for hiding this comment

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

It makes the pull request a lot easier too!

Comment on lines +6 to +7
"RotatingTensorElements",
"StixTensorElements",
Copy link
Member Author

Choose a reason for hiding this comment

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

I needed to expose these to the public API so that they could be used as return annotations without causing a "missing reference" error when doing the doc build.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain this when we next talk please?

Copy link
Member Author

Choose a reason for hiding this comment

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

Would be happy to, with the caveat that I only understand 83% of what's happening here!

@namurphy namurphy marked this pull request as ready for review February 28, 2024 16:21
@namurphy namurphy requested a review from a team as a code owner February 28, 2024 16:21
@namurphy namurphy requested review from ejohnson-96 and removed request for a team February 28, 2024 16:21
Copy link
Contributor

@ejohnson-96 ejohnson-96 left a comment

Choose a reason for hiding this comment

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

👍

@namurphy namurphy merged commit 41275ea into PlasmaPy:main Feb 28, 2024
18 checks passed
@namurphy namurphy deleted the typing-formulary-1 branch February 28, 2024 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plasmapy.formulary.quantum Related to the plasmapy.formulary.quantum module plasmapy.formulary Related to the plasmapy.formulary subpackage static type checking testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants