mdanalysis
mdanalysis copied to clipboard
Fix DeprecationWarning by using np.arctan2 for element-wise array ope…
Fixs #4339 : DeprecationWarning in nuclinfo.py for NumPy 1.25+ Compatibility
This commit resolves a DeprecationWarning related to NumPy's handling of arrays with ndim > 0, which will raise an error in future releases. Specifically, the calculation of phase_ang has been updated to use np.arctan2, ensuring element-wise array operations are handled correctly.
Changes made in this Pull Request:
- Replaced the deprecated
atan2(D, C)withnp.arctan2(D, C)to avoid scalar conversion issues. - Maintained the same logic for converting the angle to degrees.
This update ensures the codebase is future-proof for upcoming versions of NumPy.
PR Checklist
- [x] Tests?
- [x] Issue raised/referenced?
Developers certificate of origin
- [x] I certify that this contribution is covered by the LGPLv2.1+ license as defined in our LICENSE and adheres to the Developer Certificate of Origin.
📚 Documentation preview 📚: https://mdanalysis--4730.org.readthedocs.build/en/4730/
Hello @laksh-krishna-sharma! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
- In the file
package/MDAnalysis/analysis/nuclinfo.py:
Line 237:80: E501 line too long (95 > 79 characters) Line 256:1: W293 blank line contains whitespace Line 265:80: E501 line too long (104 > 79 characters) Line 271:80: E501 line too long (84 > 79 characters) Line 285:1: W293 blank line contains whitespace Line 289:80: E501 line too long (84 > 79 characters)
Comment last updated at 2024-10-15 12:19:10 UTC
Linter Bot Results:
Hi @laksh-krishna-sharma! Thanks for making this PR. We linted your code and found the following:
Some issues were found with the formatting of your code.
| Code Location | Outcome |
|---|---|
| main package | ⚠️ Possible failure |
| testsuite | ✅ Passed |
Please have a look at the darker-main-code and darker-test-code steps here for more details: https://github.com/MDAnalysis/mdanalysis/actions/runs/11345880851/job/31553733947
Please note: The black linter is purely informational, you can safely ignore these outcomes if there are no flake8 failures!
@orbeckst Sir please review the Pull Request
ok @orbeckst thanks for your response , i will make sure to do minimal changes from now and to fix the issue as soon as posible.
Look at the test output (click on Details in failing tests ❌ ) and you see that tests related to nuclinfo are now failing:
FAILED testsuite/MDAnalysisTests/analysis/test_nuclinfo.py::test_phase_as[RNAA-1-359.5758] - AssertionError:
Arrays are not almost equal to 3 decimals
ACTUAL: 89.57579515609689
DESIRED: 359.5758
FAILED testsuite/MDAnalysisTests/analysis/test_nuclinfo.py::test_phase_as[RNAA-11-171.71645] - AssertionError:
Arrays are not almost equal to 3 decimals
ACTUAL: 261.7164514291825
DESIRED: 171.71645
= 2 failed, 20003 passed, 147 skipped, 12 xfailed, 2 xpassed, 99736 warnings in 1005.44s (0:16:45) =
This means that your code changes introduced errors. You need to fix your code.
@laksh-krishna-sharma we may close this PR as stale in a week if you don't want todo further work on it.
No more activity. Closing.