Skip to content

Commit

Permalink
Compat fix for older numpy versions
Browse files Browse the repository at this point in the history
  • Loading branch information
MuellerSeb authored Apr 19, 2024
1 parent 9433c91 commit c4426fe
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/emcee/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c4426fe

Please sign in to comment.