LCOGT / snex2

Repo for the updated Supernova Exchange, built with the TOM Toolkit and used by the Global Supernova Project collaboration
https://test.supernova.exchange
GNU General Public License v3.0
0 stars 5 forks source link

`trapz` deprecated in `scipy` and `healpy` #20

Open jrfarah opened 4 months ago

jrfarah commented 4 months ago

Attempting to build snex2 on bare metal (from the branch feature/add_hermes_tns_sharing) succeeds but running throws the following error:

Traceback (most recent call last):
  File "/Users/josephfarah/Documents/phd/snex2/snex2_baremetal/snex2/manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/josephfarah/miniconda3/envs/snex2/lib/python3.10/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/Users/josephfarah/miniconda3/envs/snex2/lib/python3.10/site-packages/django/core/management/__init__.py", line 416, in execute
    django.setup()
  File "/Users/josephfarah/miniconda3/envs/snex2/lib/python3.10/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/josephfarah/miniconda3/envs/snex2/lib/python3.10/site-packages/django/apps/registry.py", line 124, in populate
    app_config.ready()
  File "/Users/josephfarah/miniconda3/envs/snex2/lib/python3.10/site-packages/tom_nonlocalizedevents/apps.py", line 8, in ready
    import tom_nonlocalizedevents.signals.handlers  # noqa
  File "/Users/josephfarah/miniconda3/envs/snex2/lib/python3.10/site-packages/tom_nonlocalizedevents/signals/handlers.py", line 8, in <module>
    from tom_nonlocalizedevents.healpix_utils import update_all_credible_region_percents_for_candidates
  File "/Users/josephfarah/miniconda3/envs/snex2/lib/python3.10/site-packages/tom_nonlocalizedevents/healpix_utils.py", line 18, in <module>
    from ligo.skymap import distance
  File "/Users/josephfarah/miniconda3/envs/snex2/lib/python3.10/site-packages/ligo/skymap/distance.py", line 38, in <module>
    import healpy as hp
  File "/Users/josephfarah/miniconda3/envs/snex2/lib/python3.10/site-packages/healpy/__init__.py", line 67, in <module>
    from .sphtfunc import (
  File "/Users/josephfarah/miniconda3/envs/snex2/lib/python3.10/site-packages/healpy/sphtfunc.py", line 27, in <module>
    from scipy.integrate import trapz
ImportError: cannot import name 'trapz' from 'scipy.integrate' (/Users/josephfarah/miniconda3/envs/snex2/lib/python3.10/site-packages/scipy/integrate/__init__.py)

The problem is originating in healpy, as scipy has moved from scipy.integrate.trapz to scipy.integrate.trapezoid for the method call. I did some investigation and discovered that this was fixed in a very recent version of healpy last month. The commit can be found here:

https://github.com/healpy/healpy/commit/93197075a6147dbf1ab176a18b3f930998ffa2cb

Commit message:

Rename trapz function from scipy.integrate module to trapezoid

However, it seems like some package in snex2 is enforcing an older version of healpy. I was able to get around the issue by enforcing the install of healpy-1.17.3 (last week's version, which for some reason is not installed with pip install healpy by default); however I don't know how this will interact with the other snex2 dependencies.

@cmccully @crpellegrino @jnation3406 I'm happy to open a PR updating the requirements.txt with this fix, if this is the best way to address the issue.

moira-andrews commented 3 months ago

I ran into this problem as well, was fixed with the solution proposed (specifically the healpy-1.17.3 installation)