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

Add test for when lorentzfactor and multiple particles are provided to gyroradius #2539

Merged

Conversation

namurphy
Copy link
Member

@namurphy namurphy commented Feb 26, 2024

This PR fixes a bug where a ValueError is raised when providing the Lorentz factor to gyroradius, along with more than one particle.

This PR adds a test for a bugfix, which was actually done in #2542. I changed the changelog entry to #2542 accordingly.

This bug probably remained hidden because we haven't added enough tests of formulary functions with ParticleList objects after decorating them with @particle_input. It probably arose in part because gyroradius has significantly higher cognitive complexity than I'd like (see also #2371).

Closes #2536. Many thanks to @jwreep for finding and reporting this bug!

@github-actions github-actions bot added plasmapy.formulary Related to the plasmapy.formulary subpackage testing labels Feb 26, 2024
@github-actions github-actions bot added the bug Issues describing unexpected behavior or defects. Remember: a bug is a sign of a missing test! label Feb 27, 2024
@namurphy namurphy added the bugfix Pull requests that fix a bug. Remember: a bug is a sign of a missing test! label Feb 27, 2024
@namurphy namurphy changed the title Fix bug in gyroradius when lorentzfactor is provided with multiple particles Fix bug when lorentzfactor and multiple particles are provided to gyroradius 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.34%. Comparing base (20e60aa) to head (5fb10bf).
Report is 44 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2539      +/-   ##
==========================================
+ Coverage   96.93%   97.34%   +0.41%     
==========================================
  Files         104      104              
  Lines        9163     9347     +184     
==========================================
+ Hits         8882     9099     +217     
+ Misses        281      248      -33     

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

@jwreep
Copy link
Contributor

jwreep commented Feb 27, 2024

Could I ask what the following means?
# noqa: C901, PLR0915

@namurphy
Copy link
Member Author

Could I ask what the following means? # noqa: C901, PLR0915

Absolutely, that is a great question! The noqa is short for "no quality assurance". The strings on the right are telling the ruff linter to ignore error codes C901 and PLR0915. The comment is essentially saying that we know that gyroradius is too long and complex, but that we should ignore those problems (at least for now).

@namurphy namurphy marked this pull request as ready for review February 27, 2024 18:13
@namurphy namurphy requested a review from a team as a code owner February 27, 2024 18:13
@namurphy namurphy requested review from ejohnson-96 and removed request for a team February 27, 2024 18:13
@namurphy
Copy link
Member Author

This PR might be partially superseded by #2542, but we'll probably still want to add the test case to make sure.

@namurphy namurphy changed the title Fix bug when lorentzfactor and multiple particles are provided to gyroradius Add test for when lorentzfactor and multiple particles are provided to gyroradius Feb 28, 2024
@namurphy namurphy removed the request for review from ejohnson-96 February 28, 2024 00:21
@namurphy namurphy merged commit ed28691 into PlasmaPy:main Feb 28, 2024
20 checks passed
@namurphy namurphy deleted the gyroradius-lorentzfactor-multiple-particles branch February 28, 2024 00:58
@namurphy namurphy removed the bug Issues describing unexpected behavior or defects. Remember: a bug is a sign of a missing test! label May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Pull requests that fix a bug. Remember: a bug is a sign of a missing test! no changelog entry needed plasmapy.formulary Related to the plasmapy.formulary subpackage testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gyroradius with lorentzfactor doesn't work with multiple particles specified
2 participants