brightway-lca / stats_arrays

BSD 3-Clause "New" or "Revised" License
1 stars 3 forks source link

SciPy>2.0.0 currently incompatible with `stats_arrays` #17

Open michaelweinold opened 2 weeks ago

michaelweinold commented 2 weeks ago

...I ran into this issue when building the Brightway Live site. I did not copy the error, but interp1d already has a depreciation warning.

cmutel commented 2 weeks ago

Sorry, I can't find interp1d used anywhere in this repo?

michaelweinold commented 2 weeks ago

I will try to re-create the error later tonight…

michaelweinold commented 2 weeks ago

Ok, the only error I was able to reproduce is when not pining scipy<2.0.0:

Error Message ``` /lib/python3.11/site-packages/scipy/__init__.py:132: UserWarning: A NumPy version >=1.21.6 and <1.28.0 is required for this version of SciPy (detected version 2.0.1) warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion}" A module that was compiled using NumPy 1.x cannot be run in NumPy 2.0.1 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0. Some module may need to rebuild instead e.g. with 'pybind11>=2.12'. If you are a user of the module, the easiest solution will be to downgrade to 'numpy<2' or try to upgrade the affected module. We expect that some modules will need time to support NumPy 2. Traceback (most recent call last): File "/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 3075, in run_cell result = self._run_cell( File "/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 3130, in _run_cell result = runner(coro) File "/lib/python3.11/site-packages/IPython/core/async_helpers.py", line 128, in _pseudo_sync_runner coro.send(None) File "/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 3334, in run_cell_async has_raised = await self.run_ast_nodes(code_ast.body, cell_name, File "/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 3517, in run_ast_nodes if await self.run_code(code, result, async_=asy): File "/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 3577, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "/tmp/xpython_42/2473045872.py", line 1, in import stats_arrays File "/lib/python3.11/site-packages/stats_arrays/__init__.py", line 33, in from .distributions import ( File "/lib/python3.11/site-packages/stats_arrays/distributions/__init__.py", line 21, in from .beta import BetaUncertainty File "/lib/python3.11/site-packages/stats_arrays/distributions/beta.py", line 4, in from scipy import stats File "/lib/python3.11/site-packages/scipy/__init__.py", line 189, in __getattr__ return _importlib.import_module(f'scipy.{name}') File "/lib/python3.11/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/lib/python3.11/site-packages/scipy/stats/__init__.py", line 608, in from ._stats_py import * File "/lib/python3.11/site-packages/scipy/stats/_stats_py.py", line 39, in from scipy.spatial.distance import cdist File "/lib/python3.11/site-packages/scipy/spatial/__init__.py", line 110, in from ._kdtree import * File "/lib/python3.11/site-packages/scipy/spatial/_kdtree.py", line 4, in from ._ckdtree import cKDTree, cKDTreeNode File "/lib/python3.11/site-packages/scipy/sparse/__init__.py", line 274, in from ._csr import * File "/lib/python3.11/site-packages/scipy/sparse/_csr.py", line 11, in from ._sparsetools import (csr_tocsc, csr_tobsr, csr_count_blocks, --------------------------------------------------------------------------- ImportError Traceback (most recent call last) Cell In[1], line 1 ----> 1 import stats_arrays File /lib/python3.11/site-packages/stats_arrays/__init__.py:33 1 __version__ = "0.7" 3 __all__ = ( 4 "BernoulliUncertainty", 5 "BetaUncertainty", (...) 30 "WeibullUncertainty", 31 ) ---> 33 from .distributions import ( 34 BernoulliUncertainty, 35 BetaUncertainty, 36 BoundedUncertaintyBase, 37 DiscreteUniform, 38 GammaUncertainty, 39 GeneralizedExtremeValueUncertainty, 40 LognormalUncertainty, 41 NormalUncertainty, 42 NoUncertainty, 43 StudentsTUncertainty, 44 TriangularUncertainty, 45 UncertaintyBase, 46 UndefinedUncertainty, 47 UniformUncertainty, 48 WeibullUncertainty, 49 ) 50 from .errors import ( 51 ImproperBoundsError, 52 InvalidParamsError, (...) 58 UnreasonableBoundsError, 59 ) 60 from .random import LatinHypercubeRNG, MCRandomNumberGenerator, RandomNumberGenerator File /lib/python3.11/site-packages/stats_arrays/distributions/__init__.py:21 19 from .base import BoundedUncertaintyBase, UncertaintyBase 20 from .bernoulli import BernoulliUncertainty ---> 21 from .beta import BetaUncertainty 22 from .discrete_uniform import DiscreteUniform 23 from .extreme import GeneralizedExtremeValueUncertainty File /lib/python3.11/site-packages/stats_arrays/distributions/beta.py:4 1 from __future__ import division 3 from numpy import isnan, linspace, random, zeros ----> 4 from scipy import stats 6 from ..errors import InvalidParamsError, ImproperBoundsError 7 from ..utils import one_row_params_array File /lib/python3.11/site-packages/scipy/__init__.py:189, in __getattr__(name) 187 def __getattr__(name): 188 if name in submodules: --> 189 return _importlib.import_module(f'scipy.{name}') 190 else: 191 try: File /lib/python3.11/importlib/__init__.py:126, in import_module(name, package) 124 break 125 level += 1 --> 126 return _bootstrap._gcd_import(name[level:], package, level) File /lib/python3.11/site-packages/scipy/stats/__init__.py:608 1 """ 2 .. _statsrefmanual: 3 (...) 603 604 """ 606 from ._warnings_errors import (ConstantInputWarning, NearConstantInputWarning, 607 DegenerateDataWarning, FitError) --> 608 from ._stats_py import * 609 from ._variation import variation 610 from .distributions import * File /lib/python3.11/site-packages/scipy/stats/_stats_py.py:39 36 from numpy.lib import NumpyVersion 37 from numpy.testing import suppress_warnings ---> 39 from scipy.spatial.distance import cdist 40 from scipy.ndimage import _measurements 41 from scipy._lib._util import (check_random_state, MapWrapper, _get_nan, 42 rng_integers, _rename_parameter, _contains_nan) File /lib/python3.11/site-packages/scipy/spatial/__init__.py:110 1 """ 2 ============================================================= 3 Spatial algorithms and data structures (:mod:`scipy.spatial`) (...) 107 QhullError 108 """ --> 110 from ._kdtree import * 111 from ._ckdtree import * 112 from ._qhull import * File /lib/python3.11/site-packages/scipy/spatial/_kdtree.py:4 1 # Copyright Anne M. Archibald 2008 2 # Released under the scipy license 3 import numpy as np ----> 4 from ._ckdtree import cKDTree, cKDTreeNode 6 __all__ = ['minkowski_distance_p', 'minkowski_distance', 7 'distance_matrix', 8 'Rectangle', 'KDTree'] 11 def minkowski_distance_p(x, y, p=2): File _ckdtree.pyx:12, in init scipy.spatial._ckdtree() File /lib/python3.11/site-packages/scipy/sparse/__init__.py:274 271 import warnings as _warnings 273 from ._base import * --> 274 from ._csr import * 275 from ._csc import * 276 from ._lil import * File /lib/python3.11/site-packages/scipy/sparse/_csr.py:11 9 from ._matrix import spmatrix, _array_doc_to_matrix 10 from ._base import _spbase, sparray ---> 11 from ._sparsetools import (csr_tocsc, csr_tobsr, csr_count_blocks, 12 get_csr_submatrix) 13 from ._sputils import upcast 15 from ._compressed import _cs_matrix ImportError: numpy.core.multiarray failed to import ```
cmutel commented 1 week ago

My conclusion is that we pin scipy<2 - we already do this for numpy, so it's not a huge change. We can change this when we have more time to investigate what is actually breaking, if anything.