mdanalysis icon indicating copy to clipboard operation
mdanalysis copied to clipboard

Fix DeprecationWarning by using np.arctan2 for element-wise array ope…

Open laksh-krishna-sharma opened this issue 1 year ago • 5 comments

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) with np.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


📚 Documentation preview 📚: https://mdanalysis--4730.org.readthedocs.build/en/4730/

laksh-krishna-sharma avatar Oct 11 '24 08:10 laksh-krishna-sharma

Hello @laksh-krishna-sharma! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

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

pep8speaks avatar Oct 11 '24 08:10 pep8speaks

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!

github-actions[bot] avatar Oct 11 '24 08:10 github-actions[bot]

@orbeckst Sir please review the Pull Request

laksh-krishna-sharma avatar Oct 11 '24 08:10 laksh-krishna-sharma

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.

laksh-krishna-sharma avatar Oct 12 '24 07:10 laksh-krishna-sharma

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.

orbeckst avatar Oct 21 '24 20:10 orbeckst

@laksh-krishna-sharma we may close this PR as stale in a week if you don't want todo further work on it.

orbeckst avatar Nov 21 '24 00:11 orbeckst

No more activity. Closing.

orbeckst avatar Nov 25 '24 20:11 orbeckst