pysep icon indicating copy to clipboard operation
pysep copied to clipboard

NumPy np.float_ function deprecated

Open SeismoFelix opened this issue 10 months ago • 4 comments

Hello,

After installing the latest version of Pysep we tried to run the pysep -l command and we obtain the following error:

pysep -l
Traceback (most recent call last):
  File "/opt/anaconda3/envs/pysep/bin/pysep", line 5, in <module>
    from pysep.pysep import main
  File "/opt/anaconda3/envs/pysep/lib/python3.13/site-packages/pysep/__init__.py", line 17, in <module>
    from pysep.pysep import Pysep, get_data  # NOQA
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/pysep/lib/python3.13/site-packages/pysep/pysep.py", line 34, in <module>
    from pysep.utils.cap_sac import (append_sac_headers, write_cap_weights_files,
                                     format_sac_header_w_taup_traveltimes,
                                     format_sac_headers_post_rotation)
  File "/opt/anaconda3/envs/pysep/lib/python3.13/site-packages/pysep/utils/cap_sac.py", line 15, in <module>
    from pysep.utils.fetch import get_taup_arrivals
  File "/opt/anaconda3/envs/pysep/lib/python3.13/site-packages/pysep/utils/fetch.py", line 7, in <module>
    from obspy.taup import TauPyModel
  File "/opt/anaconda3/envs/pysep/lib/python3.13/site-packages/obspy/taup/__init__.py", line 449, in <module>
    from .tau import TauPyModel  # NOQA
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/pysep/lib/python3.13/site-packages/obspy/taup/tau.py", line 16, in <module>
    from .helper_classes import Arrival
  File "/opt/anaconda3/envs/pysep/lib/python3.13/site-packages/obspy/taup/helper_classes.py", line 20, in <module>
    ('top_p', np.float_),
              ^^^^^^^^^
  File "/opt/anaconda3/envs/pysep/lib/python3.13/site-packages/numpy/__init__.py", line 400, in __getattr__
    raise AttributeError(
    ...<3 lines>...
    )
AttributeError: `np.float_` was removed in the NumPy 2.0 release. Use `np.float64` instead.

It seems that the subroutine np.float_ is deprecated and has to be replaced by np.float64

Thanks,

Felix

SeismoFelix avatar Mar 10 '25 18:03 SeismoFelix

Hi @SeismoFelix, it looks like this is an ObsPy related issue as they are using np.float_ in their TauP class. You would have to check to see if they are aware of this and are fixing it, my thought is that they are on the job and it should be a matter of time before a fresh download resolves this. One bandaid fix we could try is to just ignore adding arrival times from TauP until this is fixed.

bch0w avatar Mar 10 '25 19:03 bch0w

Thanks @bch0w

I checked on the newest version of ObsPy and they already updated the package to use np.float64

https://github.com/obspy/obspy/blob/master/obspy/taup/helper_classes.py#L20

Is there any chance that during Pysep installation the version of ObsPy is pinned to a version that is not compatible with NumPy > 2.0 ?

SeismoFelix avatar Mar 10 '25 21:03 SeismoFelix

Hi @SeismoFelix, that should not be the case, the environment does not have any pins on ObsPy or other packages

https://github.com/adjtomo/pysep/blob/devel/environment.yml https://github.com/adjtomo/pysep/blob/devel/pyproject.toml

I just did a fresh install of PySEP and it grabs ObsPy version 1.4.1 which was released May 2, 2024 whereas that TauP fix happened May 24, 2024, so it looks like this fix has not propagated into the Pip-installable version of ObsPy. I just manually installed NumPy<2.0.0 prior to doing a Pip install of PySEP and things seem to work.

I suppose we can pin NumPy less than 2.0.0 in PySEP until ObsPy does a version release with the NumPy fix to get around this? Let me know if that sounds like a reasonable choice as I see your point that a fresh PySEP installation currently does not work.

bch0w avatar Mar 10 '25 22:03 bch0w

Thanks @bch0w.

Indeed, it seems that the newest fix is not available via pip. Yes, I think that a bandaid fix is to pin NumPy while ObsPy makes the newest release available via pip. I will re-open a related issue in ObsPy to maintain current this situation.

Thank you so much!

SeismoFelix avatar Mar 10 '25 23:03 SeismoFelix