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

RF: Use numpy.lib.scimath to demonstrate warning context manager #1334

Merged
merged 1 commit into from
Jun 28, 2024

Conversation

jhlegarreta
Copy link
Contributor

Use numpy.lib.scimath instead of deprecated numpy.core.fromnumeric in clear_and_catch_warnings context manager doctests.

Take advantage of the commit to add an actual case that would raise a warning.

Fixes:

nibabel/testing/__init__.py::nibabel.testing.clear_and_catch_warnings
  <doctest nibabel.testing.clear_and_catch_warnings[1]>:1:
 DeprecationWarning: numpy.core is deprecated and has been renamed to
 numpy._core. The numpy._core namespace contains private NumPy internals
 and its use is discouraged, as NumPy internals can change without
 warning in any release. In practice, most real-world usage of
 numpy.core is to access functionality in the public NumPy API. If that
 is the case, use the public NumPy API. If not, you are using NumPy
 internals. If you would still like to access an internal attribute, use
 numpy._core.fromnumeric.

raised for example at:
https://github.com/nipy/nibabel/actions/runs/9692730430/job/26746686623#step:7:195

Use `numpy.lib.scimath` instead of deprecated `numpy.core.fromnumeric`
in `clear_and_catch_warnings` context manager doctests.

Take advantage of the commit to add an actual case that would raise a
warning.

Fixes:
```
nibabel/testing/__init__.py::nibabel.testing.clear_and_catch_warnings
  <doctest nibabel.testing.clear_and_catch_warnings[1]>:1:
 DeprecationWarning: numpy.core is deprecated and has been renamed to
 numpy._core. The numpy._core namespace contains private NumPy internals
 and its use is discouraged, as NumPy internals can change without
 warning in any release. In practice, most real-world usage of
 numpy.core is to access functionality in the public NumPy API. If that
 is the case, use the public NumPy API. If not, you are using NumPy
 internals. If you would still like to access an internal attribute, use
 numpy._core.fromnumeric.
```

raised for example at:
https://github.com/nipy/nibabel/actions/runs/9692730430/job/26746686623#step:7:195
@jhlegarreta
Copy link
Contributor Author

First I used numpy._core.fromnumeric following the warning, but got inspired later by Serge in
dipy/dipy@06edd04#diff-9b8d8e5f8c3c95a0b5447aec5dde61021e5ee6848a22c4952059d0a8764011f6R76

Copy link

codecov bot commented Jun 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.19%. Comparing base (0bd95cd) to head (3a7ceba).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1334      +/-   ##
==========================================
- Coverage   92.20%   92.19%   -0.01%     
==========================================
  Files          98       98              
  Lines       12398    12398              
  Branches     2556     2556              
==========================================
- Hits        11431    11430       -1     
  Misses        644      644              
- Partials      323      324       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jhlegarreta
Copy link
Contributor Author

doctest failures are unrelated.

@effigies effigies merged commit 30a5f3f into nipy:master Jun 28, 2024
48 of 49 checks passed
@jhlegarreta jhlegarreta deleted the FixNumpyCoreRenamed branch June 28, 2024 00:53
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.

2 participants