Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

laksh-krishna-sharma
Copy link
Contributor

@laksh-krishna-sharma laksh-krishna-sharma commented Oct 11, 2024

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

  • Tests?
  • Issue raised/referenced?

Developers certificate of origin


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

…rations in phase_ang calculation (NumPy 1.25+ compatibility)
@pep8speaks
Copy link

pep8speaks commented Oct 11, 2024

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

Copy link

github-actions bot commented Oct 11, 2024

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!

@laksh-krishna-sharma
Copy link
Contributor Author

@orbeckst Sir please review the Pull Request

Copy link
Member

@orbeckst orbeckst left a comment

Choose a reason for hiding this comment

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

There are many changes in this PR, most of which have nothing to do with the original issue. Please only change what needs changing to address the issue. Otherwise it takes too much time to review. The fewer changes there are in the diff view the easier it is for reviewers.

If you think that this a file needs to be refactored, open an issue, please. Note that nuclinfo is slowly being transitioned to a more modern framework #3720 so we really only want minimal changes here.

Please also check the tests (click on any of the failing tests and read the output to see where they are failing): They fail from code that you changed so you can immediately see that your changes are not correct.


.. versionadded:: 0.7.6
Copy link
Member

Choose a reason for hiding this comment

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

Do not remove docs, especially not versionadded.

@laksh-krishna-sharma
Copy link
Contributor Author

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.

Copy link
Member

@orbeckst orbeckst left a comment

Choose a reason for hiding this comment

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

Can you please create a PR that only fixes the issue and does not change any other code?

  • make sure that the tests still pass
  • demonstrate that before your changes you see the warning (e.g., just run the tests for nuclinfo: pytest -v MDAnalysisTests/analysis/test_nuclinfo.py)
  • demonstrate that after your changes you don't see the warning anymore.

You can copy and paste the output that shows warnings.

@orbeckst
Copy link
Member

orbeckst commented Oct 21, 2024

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 orbeckst self-assigned this Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants