ramonhagenaars/nptyping

numpy deprecation warnings when importing nptyping

dstansby opened this issue · 4 comments

I'm doing some testing of a package that has nptyping in the dependency chain, and when I catch the warnigns as erros with pytest some warnings are coming from nptyping:

   .tox/py38/lib/python3.8/site-packages/nrrd/formatters.py:3: in <module>
      import nptyping as npt
  .tox/py38/lib/python3.8/site-packages/nptyping/__init__.py:32: in <module>
      from nptyping.ndarray import NDArray
  .tox/py38/lib/python3.8/site-packages/nptyping/ndarray.py:40: in <module>
      from nptyping.shape import Shape
  .tox/py38/lib/python3.8/site-packages/nptyping/shape.py:29: in <module>
      from nptyping.shape_expression import (
  .tox/py38/lib/python3.8/site-packages/nptyping/shape_expression.py:36: in <module>
      from nptyping.typing_ import ShapeExpression, ShapeTuple
  .tox/py38/lib/python3.8/site-packages/nptyping/typing_.py:54: in <module>
      Object0 = np.object0
  .tox/py38/lib/python3.8/site-packages/numpy/__init__.py:294: in __getattr__
      warnings.warn(msg, DeprecationWarning, stacklevel=2)
  E   DeprecationWarning: `np.object0` is a deprecated alias for ``np.object0` is a deprecated alias for `np.object_`. `object` can be used instead.  (Deprecated NumPy 1.24)`.  (Deprecated NumPy 1.24)

Any update on this topic?
Should be rather fix to implement, dropping the legacy types. I don't mind drawing an MR for this - I an just a a bit too short sighted to fully grasp some further reaching implications.

It appears that the some type API in NumPy has changed since NumPy 1.24, starting from May 23.
Some nptyping API no longer work with the latest version of NumPy.
I'm conducting research to send a fix pull request.
I expect it will be easy to follow the new one, but harder to ensure backward compatibility.
Is it a good idea to use conditional branching to handle this?

The reason nptyping no longer works with the latest version of NumPy is likely due to these changes.

numpy/numpy#22607
numpy/numpy#22385

Currently, calling nptyping in the latest numpy environment result in an error.
I can send a pull request immediately if I just erase the API that is diprecated in numpy from nptyping to solve that, but is that the right policy?
If there are no problems, I will make that pull request in this weekend.