Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failures from scipy.integration function names deprecated in v1.14 #131

Open
mcclearyj opened this issue Jun 28, 2024 · 1 comment
Open

Comments

@mcclearyj
Copy link

Hello,

I am using the latest version of the cosmosis-standard-library, installed today in a fresh Conda environment as detailed in the CosmoSIS documentation. In building the package, Conda installed SciPy version 1.14.0 and FAST-PT version 3.1.1. I am using a Mac with an M2 chip, running MacOS Sonoma 14.4.1.

When running the examples/des_y3.ini test file, two errors were generated due to the use of deprecated scipy.integrate function names.

First, scipy.integrate.trapz in fastpt/matter_power_spt.py:

  File "/Users/j.mccleary/Software/miniconda3/envs/cosmosis/lib/python3.12/site-packages/fastpt/matter_power_spt.py", line 15, in <module>
    from scipy.integrate import trapz
ImportError: cannot import name 'trapz' from 'scipy.integrate' (/Users/j.mccleary/Software/miniconda3/envs/cosmosis/lib/python3.12/site-packages/scipy/integrate/__init__.py)

trapz appears to be deprecated in SciPy 1.14.0 and needs to be accessed with trapezoid instead. The fix is a small edit to matter_power_spt.py

Next, the use of simps instead of simpson in add_gammat_point_mass.py

  File "/Users/j.mccleary/Software/miniconda3/envs/cosmosis/lib/python3.12/site-packages/cosmosis/runtime/pipeline.py", line 633, in run
    status = module.execute(data_package)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/j.mccleary/Software/miniconda3/envs/cosmosis/lib/python3.12/site-packages/cosmosis/runtime/module.py", line 246, in execute
    return self.execute_function(data_block, self.data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/j.mccleary/Software/cosmosis-standard-library/shear/point_mass/add_gammat_point_mass.py", line 113, in execute
    int_sourcez = sp.integrate.simps(ng_array_source_rep * (num / chi_smat), z_source)
                  ^^^^^^^^^^^^^^^^^^
AttributeError: module 'scipy.integrate' has no attribute 'simps'. Did you mean: 'simpson'?

scipy.integrate.simpson only takes one positional argument (y), so the fix requires both changing simps to simpson and also specifying x:

int_sourcez = sp.integrate.simpson(ng_array_source_rep * (num / chi_smat), x=z_source)

and

betaj1j2_pm = sp.integrate.simpson(nz_lens * Is * (1./chi_lens**2), x=z_lens)

I am not sure whether this problem is specific to MacOS or whether other operating systems are affected as well. It might also be a MacOS Conda problem. I'm happy to make a branch and edit add_gammat_point_mass.py myself, but I am afraid of breaking other code/affecting other users' installations.

Since FAST-PT is also affected, I'm tagging @jablazek so he knows about the CosmoSIS aspect.

@mcclearyj mcclearyj changed the title FAST-PT failure from scipy.integration function names deprecated in v1.14 Failures from scipy.integration function names deprecated in v1.14 Jun 28, 2024
@joezuntz
Copy link
Owner

Hi @mcclearyj - thanks for finding this, it's happened in the update from scipy 1.13 to 1.14.

Since there's a bunch of other things that are also removed, for now I'll just require scipy < 1.14 in the conda dependencies.

You should hopefully be able to fix your installation by doing "conda install scipy=1.13".

I'll leave this open as a reminder to do a more general check of other pipelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants