ruptures
ruptures copied to clipboard
Getting an Error ValueError: Only callable can be used as callback when running the basic example
I am running the basic example:
import ruptures as rpt
# generate signal
n_samples, dim, sigma = 1000, 3, 4
n_bkps = 4 # number of breakpoints
signal, bkps = rpt.pw_constant(n_samples, dim, n_bkps, noise_std=sigma)
with version 1.17 But get an error:
File ~/venv/lib/python3.8/site-packages/ruptures/datasets/pw_constant.py:25, in pw_constant(n_samples, n_features, n_bkps, noise_std, delta, seed)
11 """Return a piecewise constant signal and the associated changepoints.
12
13 Args:
(...)
22 tuple: signal of shape (n_samples, n_features), list of breakpoints
23 """
24 # breakpoints
---> 25 bkps = draw_bkps(n_samples, n_bkps, seed=seed)
26 # we create the signal
27 signal = np.empty((n_samples, n_features), dtype=float)
File ~/venv/lib/python3.8/site-packages/ruptures/utils/drawbkps.py:9, in draw_bkps(n_samples, n_bkps, seed)
6 def draw_bkps(n_samples=100, n_bkps=3, seed=None):
7 """Draw a random partition with specified number of samples and specified
8 number of changes."""
----> 9 rng = np.random.default_rng(seed=seed)
10 alpha = np.ones(n_bkps + 1) / (n_bkps + 1) * 2000
11 bkps = np.cumsum(rng.dirichlet(alpha) * n_samples).astype(int).tolist()
File _generator.pyx:4360, in numpy.random._generator.default_rng()
File _pcg64.pyx:118, in numpy.random._pcg64.PCG64.__init__()
File /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/contextlib.py:74, in ContextDecorator.__call__.<locals>.inner(*args, **kwds)
72 @wraps(func)
73 def inner(*args, **kwds):
---> 74 with self._recreate_cm():
75 return func(*args, **kwds)
File ~/venv/lib/python3.8/site-packages/numpy/core/_ufunc_config.py:436, in __enter__(self)
434 def __exit__(self, *exc_info):
435 seterr(**self.oldstate)
--> 436 if self.call is not _Unspecified:
437 seterrcall(self.oldcall)
File ~/venv/lib/python3.8/site-packages/numpy/core/_ufunc_config.py:305, in seterrcall(func)
302 if func is not None and not isinstance(func, collections.abc.Callable):
303 if (not hasattr(func, 'write') or
304 not isinstance(func.write, collections.abc.Callable)):
--> 305 raise ValueError("Only callable can be used as callback")
306 pyvals = umath.geterrobj()
307 old = geterrcall()
ValueError: Only callable can be used as callback
Any idea what I can do?
Could not reproduce with
- python v3.8.10
- ruptures-1.1.7
- numpy-1.23.1
- scipy-1.9.0
Could you force a reinstall on numpy ? pip install --force-reinstall --no-cache-dir numpy
closing for now.