diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 063f0c0a..b5c677b5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -49,12 +49,17 @@ jobs: COVERALLS_PARALLEL: true COVERALLS_FLAG_NAME: ${{ matrix.python-version }}-${{ matrix.os }} - leading_edge: + numpy_edge: runs-on: ${{ matrix.os }} strategy: matrix: python-version: ["3.12"] + numpy-version: ["numpy>=2.0.0rc1"] os: ["ubuntu-latest"] + include: + - python-version: "3.9" + numpy-version: "numpy<1.25" + os: "ubuntu-latest" steps: - name: Checkout @@ -68,7 +73,7 @@ jobs: - name: Install dependencies run: | python -m pip install -U pip - python -m pip install pip install pytest "numpy>=2.0.0rc1" + python -m pip install pip install pytest "${{ matrix.numpy-version }}" python -m pip install -e. - name: Run tests run: pytest diff --git a/src/emcee/ensemble.py b/src/emcee/ensemble.py index cfef4a57..c71f6ee5 100644 --- a/src/emcee/ensemble.py +++ b/src/emcee/ensemble.py @@ -21,6 +21,13 @@ # for py2.7, will be an Exception in 3.8 from collections import Iterable +try: + # Try to import from numpy.exceptions (available in NumPy 1.25 and later) + from numpy.exceptions import VisibleDeprecationWarning +except ImportError: + # Fallback to the top-level numpy import (for older versions) + from numpy import VisibleDeprecationWarning + class EnsembleSampler(object): """An ensemble MCMC sampler @@ -511,7 +518,7 @@ def compute_log_prob(self, coords): try: with warnings.catch_warnings(record=True): warnings.simplefilter( - "error", np.exceptions.VisibleDeprecationWarning + "error", VisibleDeprecationWarning ) try: dt = np.atleast_1d(blob[0]).dtype