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

Remove mutable arguments from Particle.is_category method #751

Merged
merged 2 commits into from
Feb 3, 2020

Conversation

jakub-polak
Copy link
Contributor

I noticed that there are mutable arguments in Particle.is_category method, that should never be done.
Nice article about its 'features' --> https://florimond.dev/blog/articles/2018/08/python-mutable-defaults-are-the-source-of-all-evil/

So the mutable arguments are removed and replaced by None with handling by become_set similarly as it was before.

@codecov
Copy link

codecov bot commented Feb 2, 2020

Codecov Report

Merging #751 into master will increase coverage by 1.2%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #751     +/-   ##
=========================================
+ Coverage   95.06%   96.26%   +1.2%     
=========================================
  Files          56       55      -1     
  Lines        5047     4957     -90     
=========================================
- Hits         4798     4772     -26     
+ Misses        249      185     -64
Impacted Files Coverage Δ
plasmapy/atomic/particle_class.py 96.64% <100%> (ø) ⬆️
plasmapy/__init__.py 53.33% <0%> (-5.5%) ⬇️
plasmapy/formulary/quantum.py 65.85% <0%> (-2.44%) ⬇️
plasmapy/classes/sources/openpmd_hdf5.py 79.56% <0%> (-1.75%) ⬇️
plasmapy/diagnostics/langmuir.py 93.21% <0%> (-0.07%) ⬇️
plasmapy/formulary/mathematics.py 100% <0%> (ø) ⬆️
plasmapy/utils/pytest_helpers/__init__.py 100% <0%> (ø) ⬆️
plasmapy/utils/__init__.py 100% <0%> (ø) ⬆️
plasmapy/classes/sources/plasmablob.py 100% <0%> (ø) ⬆️
plasmapy/utils/pytest_helpers/error_messages.py
... and 3 more

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 46a7779...cbcb9f6. Read the comment docs.

@jakub-polak jakub-polak changed the title Remove mutable arguments from is_category function Remove mutable arguments from Particle.is_category method Feb 2, 2020
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.

That's a fair point, I didn't think of that. LGTM! @namurphy, wanna take a look?

@namurphy namurphy added the plasmapy.particles Related to the plasmapy.particles subpackage label Feb 3, 2020
@namurphy
Copy link
Member

namurphy commented Feb 3, 2020

Thank you! Looks good to me too, so I'll merge it. I'll create a broader issue for us to check if there are mutable default arguments elsewhere in the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plasmapy.particles Related to the plasmapy.particles subpackage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants