AstroPhot icon indicating copy to clipboard operation
AstroPhot copied to clipboard

Update to numpy 2.0

Open wmwv opened this issue 7 months ago • 11 comments

Describe the bug A clear and concise description of what the bug is.

numpy 2.0 has a variety of changes, the vast majority of which are automatable.

https://numpy.org/devdocs/numpy_2_0_migration_guide.html#numpy-2-migration-guide

The automatic tool ruff says the only two needed changes are amusingly about getting the type right for ignoring numpy VisibleDeprecationWarning :)

[Calm-4 AstroPhot] ruff check astrophot --select NPY201
astrophot/utils/decorators.py:21:52: NPY201 [*] `np.VisibleDeprecationWarning` will be removed in NumPy 2.0. Use `numpy.exceptions.VisibleDeprecationWarning` instead.
   |
19 |     def wrapped(*args, **kwargs):
20 |         old_settings = np.seterr(all="ignore")
21 |         warnings.filterwarnings("ignore", category=np.VisibleDeprecationWarning)
   |                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY201
22 |         result = func(*args, **kwargs)
23 |         np.seterr(**old_settings)
   |
   = help: Replace with `numpy.exceptions.VisibleDeprecationWarning`

astrophot/utils/decorators.py:24:53: NPY201 [*] `np.VisibleDeprecationWarning` will be removed in NumPy 2.0. Use `numpy.exceptions.VisibleDeprecationWarning` instead.
   |
22 |         result = func(*args, **kwargs)
23 |         np.seterr(**old_settings)
24 |         warnings.filterwarnings("default", category=np.VisibleDeprecationWarning)
   |                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY201
25 |         return result
   |
   = help: Replace with `numpy.exceptions.VisibleDeprecationWarning`

Found 2 errors.
[*] 2 fixable with the `--fix` option.

wmwv avatar Jul 17 '24 19:07 wmwv