Fix incorrect unit conversion factors in units.py#5053
Fix incorrect unit conversion factors in units.py#5053orbeckst merged 18 commits intoMDAnalysis:developfrom
Conversation
There was a problem hiding this comment.
Hello there first time contributor! Welcome to the MDAnalysis community! We ask that all contributors abide by our Code of Conduct and that first time contributors introduce themselves on GitHub Discussions so we can get to know you. You can learn more about participating here. Please also add yourself to package/AUTHORS as part of this PR.
…cities for test consistency
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #5053 +/- ##
===========================================
- Coverage 92.68% 92.67% -0.01%
===========================================
Files 180 180
Lines 22452 22452
Branches 3186 3186
===========================================
- Hits 20810 20808 -2
- Misses 1167 1170 +3
+ Partials 475 474 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
orbeckst
left a comment
There was a problem hiding this comment.
Thank you VERY much for finding this very old bug. I assume you found it while working with LAMMPS files? Great work fixing and also updating the tests.
Please address the following points (see inline comments for details)
- update CHANGELOG (include your GitHub handle and rewrite/add entries a bit)
- please add Å/nm to the conversions (I will merge your PR if you don't do it but it would be nice as it fits directly in with your fix)
- please remove the formatting change to the LAMMPS writer, we'd like to keep PRs focused on one thing
Apologies that it took a while to review your PR.
| for index, vel in zip(indices, velocities): | ||
| self.f.write( | ||
| "{i:d} {x:f} {y:f} {z:f}\n".format( | ||
| "{i:d} {x:.8f} {y:.8f} {z:.8f}\n".format( |
There was a problem hiding this comment.
This may be useful but does not belong into this PR. Please revert and make a separate PR – then people knowledgable about LAMMPS can discuss.
There was a problem hiding this comment.
It seems that the writer test does not pass unless we force higher precision. Our LAMMPS test files have 10 decimals so I am tentatively setting all output to .10f.
|
@raulloiscuns it would be great to add your fix to MDAnalysis soon. Are you able to address the review comments? |
orbeckst
left a comment
There was a problem hiding this comment.
I am finishing the PR so that we can include it in the 2.10.0 release.
| for index, vel in zip(indices, velocities): | ||
| self.f.write( | ||
| "{i:d} {x:f} {y:f} {z:f}\n".format( | ||
| "{i:d} {x:.8f} {y:.8f} {z:.8f}\n".format( |
IAlibay
left a comment
There was a problem hiding this comment.
I'm not reviewing this PR, but please do order the changelog entries properly to save me time on release.
package/CHANGELOG
Outdated
| * Fixes the benchmark `SimpleRmsBench` in `benchmarks/analysis/rms.py` | ||
| by changing the way weights for RMSD are calculated, instead of | ||
| directly passing them. (Issue #3520, PR #5006) | ||
| * Fixes incorrect conversion factors for speed units A/fs, A/us, A/ms |
There was a problem hiding this comment.
Please put things done in this PR at the top of the entry list.
|
I am using pre-commit with black 24 and it passes and then our linters/black fails; I probably need to sync the settings in some way, until then there'll be more micro commits of the type "blackened file xxx" (which I'll squash merge). |
IAlibay
left a comment
There was a problem hiding this comment.
I might as well actually review rather than just lurk.
There was a problem hiding this comment.
Not this PR, just a general comment. We should probably come up with some kind of rule about autoformatting the changelog, personally not sure it makes sense to have black apply to it since it's just free-form text.
There was a problem hiding this comment.
Sorry, didn't see that it removed all the trailing whitespace.
This is my fault for not configuring pre-commit hook properly (or disabling it). It won't let me commit until it's happy and I may just not have the right .pre-commit-config.yaml.
There was a problem hiding this comment.
I think it wasn't black that touched CHANGELOG because when I only committed CHANGELOG, black did not engage
(mda-develop) mac:MDAnalysisTests oliver$ git commit --amend
black................................................(no files to check)Skipped
flake8...............................................(no files to check)Skipped
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check for merge conflicts................................................Passed
Instead it's likely the trim trailing whitespace plugin for pre-commit.
It would be great to have an expert share a pre-commit yaml file for MDA development.
cc @RMeli |
- add tests for unit conversion with unicode characters - add additional representations Å/us, Å/µs, Å/fs, Å/ms
There was a problem hiding this comment.
Sorry for the noise. When I reverted a change, pre-commit/flake/black were all unhappy about the file so I did some line breaking and a single real fix.
- match precision in our test files - required for tests to pass when round-tripping velocities - updated CHANGELOG
|
Thanks @IAlibay , just updated CHANGELOG with output precision changes and ran black locally again. I think I just don't have the right settings for pre-commit black and our black and need to sort that out. If the latest changes pass our CI, I'll also approve and squash-merge. Thanks a lot for your extra 👀 — much appreciated! |
|
(This got automerged on approval... I had thought it would wait for all of CI... oops, sorry. All linters and Linux had passed at least. If anything gets messed up on develop I'll fix it.) |
|
@raulloiscuns your PR got merged and your fix will be in 2.10.0. 🎉 Thank you very much for identifying the problem and proposing a solution! |
|
I am using the following Details# Pre-commit configuration for MDAnalysis
repos:
# Black - Python code formatter
- repo: https://github.com/psf/black
# workaround https://github.com/psf/black/issues/2493#issuecomment-1081987650
rev: 'refs/tags/24.10.0:refs/tags/24.10.0'
hooks:
- id: black
language_version: python3
# Use project's Black configuration from pyproject.toml
files: \.(py)$
# Flake8 - Python linter (more lenient for this project)
- repo: https://github.com/pycqa/flake8
rev: 7.3.0
hooks:
- id: flake8
args: [
--max-line-length=88,
"--extend-ignore=E203,W503,F401,F841,E722,E711,E712,E713,E714,F811"
]
files: \.(py)$
# Additional useful hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-merge-conflictand I would have hoped that it fixes anything that our GH linters would find offensive. Instead, I had to repeatedly manually run I probably didn't configure my pre-commit exactly the way that MDAnalysis wants it. A sample yaml file that "just works" would be useful. |
Fixes #5051
Changes made in this Pull Request:
The conversion factors for A/fs, A/ms and A/us have been revised and corrected in
units.py.PR Checklist
package/CHANGELOGfile updated?package/AUTHORS? (If it is not, add it!)Developers Certificate of Origin
I certify that I can submit this code contribution as described in the Developer Certificate of Origin, under the MDAnalysis LICENSE.
📚 Documentation preview 📚: https://mdanalysis--5053.org.readthedocs.build/en/5053/