diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 4005afa5..d3847049 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -44,6 +44,7 @@ jobs: - name: Upgrade pip and install doc requirements run: | python -m pip install --upgrade pip + python -m pip install numpy~=1.0 python -m pip install -e ".[all,docs]" - name: build documentation run: | diff --git a/README.rst b/README.rst index 4ecb81c2..ef3fb652 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ anesthetic: nested sampling post-processing =========================================== :Authors: Will Handley and Lukas Hergt -:Version: 2.9.0 +:Version: 2.9.1 :Homepage: https://github.com/handley-lab/anesthetic :Documentation: http://anesthetic.readthedocs.io/ diff --git a/anesthetic/_version.py b/anesthetic/_version.py index 387cfacc..b03f5b5d 100644 --- a/anesthetic/_version.py +++ b/anesthetic/_version.py @@ -1 +1 @@ -__version__ = '2.9.0' +__version__ = '2.9.1' diff --git a/anesthetic/plot.py b/anesthetic/plot.py index 05bedacf..f080ab3a 100644 --- a/anesthetic/plot.py +++ b/anesthetic/plot.py @@ -9,6 +9,7 @@ to create a set of axes and legend proxies. """ +from packaging import version import numpy as np from pandas import Series, DataFrame import matplotlib.pyplot as plt @@ -839,7 +840,11 @@ def fastkde_plot_1d(ax, data, *args, **kwargs): p /= p.max() i = ((x > quantile(x, q[0], p)) & (x < quantile(x, q[-1], p))) - area = np.trapz(x=x[i], y=p[i]) if density else 1 + if version.parse(np.__version__) >= version.parse("2.0.0"): + trapezoid = np.trapezoid + else: + trapezoid = np.trapz + area = trapezoid(x=x[i], y=p[i]) if density else 1 if ax.get_xaxis().get_scale() == 'log': x = 10**x ans = ax.plot(x[i], p[i]/area, color=color, *args, **kwargs) @@ -962,7 +967,11 @@ def kde_plot_1d(ax, data, *args, **kwargs): bw = np.sqrt(kde.covariance[0, 0]) pp = cut_and_normalise_gaussian(x, p, bw, xmin=data.min(), xmax=data.max()) pp /= pp.max() - area = np.trapz(x=x, y=pp) if density else 1 + if version.parse(np.__version__) >= version.parse("2.0.0"): + trapezoid = np.trapezoid + else: + trapezoid = np.trapz + area = trapezoid(x=x, y=pp) if density else 1 if ax.get_xaxis().get_scale() == 'log': x = 10**x ans = ax.plot(x, pp/area, color=color, *args, **kwargs) diff --git a/pyproject.toml b/pyproject.toml index 61a00b37..dbb36b74 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,7 @@ license = {file = "LICENSE"} requires-python = ">=3.8" dependencies = [ "scipy<2.0.0", - "numpy<2.0.0", + "numpy>=1.26.0,<3.0.0", "pandas~=2.2.0", "matplotlib>=3.6.1,<3.10.0", ] diff --git a/tests/utils.py b/tests/utils.py index 8c1c72cd..2dfcd720 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,12 +1,12 @@ +from importlib.util import find_spec import pytest -import sys try: import astropy # noqa: F401 except ImportError: pass -condition = 'astropy' not in sys.modules +condition = find_spec('astropy') is None reason = "requires astropy package" raises = ImportError astropy_mark_skip = pytest.mark.skipif(condition, reason=reason) @@ -22,7 +22,7 @@ def skipif_no_astropy(param): except ImportError: pass reason = "requires fastkde package" -condition = 'fastkde' not in sys.modules +condition = find_spec('fastkde') is None raises = ImportError fastkde_mark_skip = pytest.mark.skipif(condition, reason=reason) fastkde_mark_xfail = pytest.mark.xfail(condition, raises=raises, reason=reason) @@ -36,7 +36,7 @@ def skipif_no_fastkde(param): import getdist # noqa: F401 except ImportError: pass -condition = 'getdist' not in sys.modules +condition = find_spec('getdist') is None reason = "requires getdist package" raises = ImportError getdist_mark_skip = pytest.mark.skipif(condition, reason=reason) @@ -65,7 +65,7 @@ def skipif_no_getdist(param): except ImportError: pass -condition = 'h5py' not in sys.modules +condition = find_spec('h5py') is None reason = "requires h5py package" raises = ImportError h5py_mark_skip = pytest.mark.skipif(condition, reason=reason)