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

Added Tests for Verify correctness in MaxwellianCollisionFrequencies #2614

Merged
merged 7 commits into from
Apr 4, 2024

Conversation

daran9
Copy link
Contributor

@daran9 daran9 commented Apr 3, 2024

Description

Added Tests to verify correctness of for the following two properties in MaxwellianCollisionFrequencies :

  • Maxwellian_avg_ei_collision_freq
  • Maxwellian_avg_ii_collision_freq

Motivation and context

Related issues

PR for the Issue
Closes #2333

Copy link

github-actions bot commented Apr 3, 2024

Thank you for submitting a pull request (PR) to PlasmaPy! ✨ The future of the project depends on contributors like you, so we deeply appreciate it! 🌱

Our contributor guide has information on:

The bottom of this page shows several checks that are run for every PR. Don't worry if something broke! We break stuff all the time. 😺 Click on "Details" to learn why a check didn't pass. Please also feel free to ask for help. We do that all the time as well. 🌸 You can find us in our chat room or weekly community meeting & office hours. Here are some tips:

  • Try fixing CI / Python 3.12 test failures first.
  • Most pre-commit.ci - pr failures can be automagically fixed by commenting pre-commit.ci autofix below, followed by a git pull to bring the changes back to your computer. Please also see our pre-commit troubleshooting guide.
  • If pre-commit.ci - pr says that a function is too long or complex, try breaking up that function into multiple short functions that each do one thing. See also these tips on writing clean scientific software.
  • If the CI / Documentation check ends with a cryptic error message, check out our documentation troubleshooting guide.
  • For a documentation preview, click on Details next to docs/readthedocs.org:plasmapy.

If this PR is marked as ready for review, someone should stop by to provide a code review and offer suggestions soon. ✅ If you don't get a review within a few days, please feel free to send us a reminder.

Please also use SI units within PlasmaPy, except when there is strong justification otherwise or in some examples.

We thank you once again!

@github-actions github-actions bot added plasmapy.formulary Related to the plasmapy.formulary subpackage testing packaging Related to packaging or distribution labels Apr 3, 2024
Copy link

codecov bot commented Apr 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.17%. Comparing base (bb3e223) to head (c34a252).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2614      +/-   ##
==========================================
- Coverage   95.18%   95.17%   -0.02%     
==========================================
  Files         104      104              
  Lines        9415     9415              
  Branches     2154     2154              
==========================================
- Hits         8962     8961       -1     
  Misses        276      276              
- Partials      177      178       +1     

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

@daran9 daran9 marked this pull request as ready for review April 3, 2024 21:32
@daran9 daran9 requested a review from a team as a code owner April 3, 2024 21:32
@daran9 daran9 requested review from ejohnson-96 and removed request for a team April 3, 2024 21:32
Copy link
Member

@pheuer pheuer left a comment

Choose a reason for hiding this comment

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

Thanks for doing this! I think the test looks good - one minor comment below.

I think the failing test might be because of an increase of coverage on main, so if you merge main into this branch that might be resolved?

@@ -708,7 +753,7 @@ def test_fail1(self) -> None:
"""
fail1 = self.True1 * (1 + 1e-15)
with pytest.warns(PhysicsWarning, match="strong coupling effects"):
methodVal = collision_frequency(
methodVal: u.Quantity = collision_frequency(
Copy link
Member

Choose a reason for hiding this comment

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

Is this type hinting necessary? It looks like collision_frequency has its own type hint that inidicates that it returns a Quantity.

def collision_frequency(
    T: u.Quantity[u.K],
    n: u.Quantity[u.m**-3],
    species,
    z_mean: float = np.nan,
    V: u.Quantity[u.m / u.s] = np.nan * u.m / u.s,
    method="classical",
) -> u.Quantity[u.Hz]:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure how that was modified; I have removed it.

Copy link
Member

Choose a reason for hiding this comment

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

One possibility is that this was an automated refactoring by an IDE. 🤔 I've infrequently had unintentional changes from IDEs sneak in to pull requests before, like removing imports. In any case, thanks for removing it!

Copy link
Member

@namurphy namurphy left a comment

Choose a reason for hiding this comment

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

LGTM! 👍🏻 Thank you again for doing this! 🚀

It's good to see that Codecov appears to be working again. The problem was that this PR was being compared against a commit that was two months old because of a problem with the Codecov token not being recognized.

I have some slight edits to the changelog which I'll merge, and then set this PR to auto-merge once tests pass again.

Thank you again!

changelog/2614.trivial.rst Outdated Show resolved Hide resolved
@namurphy namurphy enabled auto-merge (squash) April 4, 2024 16:55
],
)
@pytest.mark.filterwarnings("ignore::plasmapy.utils.exceptions.RelativityWarning")
def test_correctness_collision_freq_values(
Copy link
Member

@pheuer pheuer Apr 4, 2024

Choose a reason for hiding this comment

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

@namurphy Isn't there a name for when you test software to see if it reproduces a previously recorded output?

I'd suggest we change the name here to test_collision_freq_values_match_previous_evaluation or something, since correctness implies that the actual physics is being tested here? Unless these numbers are coming from a by-hand calculation, in which case this test is an independent verification of the physics in code?

Edit: This is pretty minor point, so I don't want to hold up the merge, just something for discussion.

@namurphy namurphy merged commit 77301a6 into PlasmaPy:main Apr 4, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packaging Related to packaging or distribution plasmapy.formulary Related to the plasmapy.formulary subpackage testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Verify correctness of two methods in MaxwellianCollisionFrequencies
3 participants