numpyencoder icon indicating copy to clipboard operation
numpyencoder copied to clipboard

Numpy 2.0 deprecations

Open ns-rse opened this issue 1 year ago • 4 comments

Further to #5 and #6 np.complex_ deprecation needs correctly handling such as to maintain backwards compatibility as it throws up errors when run with newer versions of Numpy...

  File "/Users/sylvi/.pyenv/versions/3.11.9/envs/topostats/lib/python3.11/site-packages/numpyencoder/numpyencoder.py", line 31, in default
    elif isinstance(obj, (np.complex_, np.complex64, np.complex128)):
                          ^^^^^^^^^^^
  File "/Users/sylvi/.pyenv/versions/3.11.9/envs/topostats/lib/python3.11/site-packages/numpy/__init__.py", line 400, in __getattr__
    raise AttributeError(
AttributeError: `np.complex_` was removed in the NumPy 2.0 release. Use `np.complex128` instead.

See here for more context.

Removing it completely as per #6 would, as noted, break backwards compatibility of numpyencoder.

I've never had to deal with such deprecations and maintaining backwards compatibility before but please let me know if there is anything I can do to help.

ns-rse avatar Jun 03 '25 11:06 ns-rse

Just ran into this issue, I guess this hasn't been fixed yet? Is there anyway around this other than just not using the numpyencoder?

JonahDW avatar Jul 07 '25 12:07 JonahDW

ran into this issue too. Not sure what to do next.

tatianaanthony avatar Jul 12 '25 23:07 tatianaanthony

@JonahDW and @tatianaanthony I'm merging a fix that solves this for all NumPy versions now and should have a new package available for upgrade shortly after. Sorry this has caused an issue for you.

hmallen avatar Jul 14 '25 07:07 hmallen

Issue has been fixed in v0.3.2 and published to pypi.

hmallen avatar Jul 15 '25 04:07 hmallen