pace-neutrons / Euphonic

Euphonic is a Python package for efficient simulation of phonon bandstructures, density of states and inelastic neutron scattering intensities from force constants.
GNU General Public License v3.0
29 stars 11 forks source link

Clean up a bit using new dependencies #288

Closed ajjackson closed 1 year ago

ajjackson commented 1 year ago

Using some features of Python 3.8+ and newer Numpy

I tried not to go too crazy, there are more places where assignment expressions (i.e. walrus) could be used to save a line but overall flow and clarity don't really benefit.

codecov-commenter commented 1 year ago

Codecov Report

Merging #288 (f10d6c4) into master (7c8b90a) will increase coverage by 0.06%. The diff coverage is 96.26%.

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the GitHub App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master     #288      +/-   ##
==========================================
+ Coverage   95.79%   95.85%   +0.06%     
==========================================
  Files          28       28              
  Lines        3992     3983       -9     
  Branches      803      803              
==========================================
- Hits         3824     3818       -6     
+ Misses         99       97       -2     
+ Partials       69       68       -1     
Files Changed Coverage Δ
euphonic/util.py 95.79% <81.81%> (+0.01%) :arrow_up:
euphonic/spectra.py 95.16% <93.33%> (-0.01%) :arrow_down:
euphonic/broadening.py 82.82% <100.00%> (+0.53%) :arrow_up:
euphonic/crystal.py 90.82% <100.00%> (-0.33%) :arrow_down:
euphonic/force_constants.py 99.65% <100.00%> (+<0.01%) :arrow_up:
euphonic/plot.py 100.00% <100.00%> (ø)
euphonic/powder.py 96.87% <100.00%> (+0.04%) :arrow_up:
euphonic/qpoint_frequencies.py 99.13% <100.00%> (+<0.01%) :arrow_up:
euphonic/qpoint_phonon_modes.py 98.83% <100.00%> (+0.01%) :arrow_up:
euphonic/readers/castep.py 96.04% <100.00%> (+0.88%) :arrow_up:
... and 2 more

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

github-actions[bot] commented 1 year ago

Test Results

       22 files  ±0         22 suites  ±0   52m 54s :stopwatch: - 2m 7s   1 049 tests ±0    1 043 :heavy_check_mark: ±0    6 :zzz: ±0  0 :x: ±0  10 430 runs  ±0  10 367 :heavy_check_mark: ±0  63 :zzz: ±0  0 :x: ±0 

Results for commit f10d6c47. ± Comparison against base commit 7c8b90a5.

:recycle: This comment has been updated with latest results.

ajjackson commented 1 year ago

I have used the Literal type annotation everywhere I could find strings being used to switch between a few options.

Another possible tool for this kind of thing is Enum. Python 3.11 introduces the StrEnum which could be especially nice for doing this in a backward-compatible way.

ajjackson commented 1 year ago

I'm baffled by these codacy errors. Those items are clearly type-hinted as Quantity. They assert as Quantity. mypy doesn't complain about them. Why is Codacy convinced they are numpy arrays?

(mypy doesn't like that they are indexed, though. Which is a bit strange; how does it complain that it doesn't have stubs for pint, but also that it doesn't think Quantity should be indexable?)

ajjackson commented 1 year ago

I think the .pylintrc has to be pushed to master branch before it will be used by Codacy :-(

ajjackson commented 1 year ago

That seems to have fixed it :tada: . I had to also edit the codacy settings to look for a pylintrc file.