nipy / nibabel

Python package to access a cacophony of neuro-imaging file formats
http://nipy.org/nibabel/
Other
634 stars 258 forks source link

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

Closed jhlegarreta closed 1 week ago

jhlegarreta commented 1 week ago

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 commented 1 week ago

First I used numpy._core.fromnumeric following the warning, but got inspired later by Serge in https://github.com/dipy/dipy/pull/3274/commits/06edd043ca6da762d5a713688a93c8b6eee1ab42#diff-9b8d8e5f8c3c95a0b5447aec5dde61021e5ee6848a22c4952059d0a8764011f6R76

codecov[bot] commented 1 week ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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

Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

jhlegarreta commented 1 week ago

doctest failures are unrelated.