Visitar URL original
change os.path to pathlib by MKastek · Pull Request #1690 · PlasmaPy/PlasmaPy · GitHub
Skip to content

change os.path to pathlib - #1690

Merged
StanczakDominik merged 14 commits into
PlasmaPy:mainfrom
MKastek:switch-to-using-pathlib
Aug 25, 2022
Merged

StanczakDominik merged 14 commits into
PlasmaPy:mainfrom
MKastek:switch-to-using-pathlib

Conversation

@MKastek

@MKastek MKastek commented Aug 24, 2022 •

Copy link
Copy Markdown
Contributor
  • I have added a changelog entry for this pull request.
  • If adding new functionality, I have added tests and
    docstrings.
  • I have fixed any newly failing tests.

Closes #1684

@github-actions github-actions Bot added plasmapy.diagnostics Related to the plasmapy.diagnostics subpackage plasmapy.particles Related to the plasmapy.particles subpackage plasmapy.plasma Related to the plasmapy.plasma subpackage labels Aug 24, 2022
@MKastek

MKastek commented Aug 24, 2022

Copy link
Copy Markdown
Contributor Author

pre-commit.ci autofix

@MKastek

MKastek commented Aug 24, 2022

Copy link
Copy Markdown
Contributor Author

pre-commit.ci autofix

@codecov

codecov Bot commented Aug 24, 2022 •

Copy link
Copy Markdown

Codecov Report

Merging #1690 (8f2a151) into main (d3b597a) will increase coverage by 0.41%.
The diff coverage is 83.33%.

@@            Coverage Diff             @@
##             main    #1690      +/-   ##
==========================================
+ Coverage   97.21%   97.63%   +0.41%     
==========================================
  Files          83       85       +2     
  Lines        7961     8020      +59     
==========================================
+ Hits         7739     7830      +91     
+ Misses        222      190      -32     
Impacted Files Coverage Δ
plasmapy/plasma/sources/openpmd_hdf5.py 82.41% <66.66%> (+0.89%) ⬆️
plasmapy/particles/data/test/__init__.py 100.00% <100.00%> (ø)
plasmapy/particles/ionization_state.py 94.06% <0.00%> (-0.14%) ⬇️
plasmapy/particles/particle_class.py 98.99% <0.00%> (-0.01%) ⬇️
plasmapy/particles/atomic.py 100.00% <0.00%> (ø)
plasmapy/formulary/__init__.py 100.00% <0.00%> (ø)
plasmapy/particles/__init__.py 95.83% <0.00%> (ø)
plasmapy/formulary/parameters.py 100.00% <0.00%> (ø)
plasmapy/formulary/dimensionless.py 100.00% <0.00%> (ø)
plasmapy/dispersion/numerical/hollweg_.py 100.00% <0.00%> (ø)
... and 8 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@StanczakDominik StanczakDominik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some minor possible changes to make this more idiomatic for pathlib, also coverage seems to have gone down a little but I'm not investigating THAT from my phone :D if I don't get to it in time, can you take a look and see which lines are newly untested and why? If it's just that there's fewer total lines in the files, we can live with that

Comment on lines +9 to +10
data_dir = Path(__file__).parents[0]
data_files = glob.glob(str(data_dir.joinpath("*.[!p]*")))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't Path objects provide their own glob method? So you wouldn't need the extension glob import nor the str conversion?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes Path objects provide glob method, it returns generator so I turned it to list.

MKastek and others added 2 commits August 25, 2022 09:00
Co-authored-by: Dominik Stańczak-Marikin <stanczakdominik@gmail.com>
@MKastek

MKastek commented Aug 25, 2022

Copy link
Copy Markdown
Contributor Author

pre-commit.ci autofix


isfile = os.path.isfile(hdf5)
if not isfile:
if not Path(hdf5).is_file():

@MKastek MKastek Aug 25, 2022 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This line of code is not covered by tests. @StanczakDominik

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, missed that comment. Let me still investigate this before merging .

@StanczakDominik StanczakDominik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

All right! I'll just change the changelog a little for nicer display in the docs. Thanks!

Comment on lines +614 to 615
path = str(tmp_path / "temp.npz")
sim.save_results(path)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So this test failed without str because save_results explicitly wants a string? We should probably fix that sometime, but it's fine for now.

Comment thread changelog/1690.feature.rst Resolved
Co-authored-by: Dominik Stańczak-Marikin <stanczakdominik@gmail.com>
@StanczakDominik

Copy link
Copy Markdown
Member

Ah, yeah, that looks fine. We'll be rewriting the plasma classes anyway (as in #1687).

@StanczakDominik
StanczakDominik merged commit 9ef6671 into PlasmaPy:main Aug 25, 2022
namurphy added a commit to namurphy/PlasmaPy that referenced this pull request Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plasmapy.diagnostics Related to the plasmapy.diagnostics subpackage plasmapy.particles Related to the plasmapy.particles subpackage plasmapy.plasma Related to the plasmapy.plasma subpackage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switch to using pathlib instead of os.path

2 participants