-
Notifications
You must be signed in to change notification settings - Fork 667
Open
Description
Hi, I am currently trying to execute the code in your Notebook on Kalman filters. In the Multivariate Gaussians section this error is thrown, which seems to be an allocation problem in filterpy
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[19], line 7
3 mean = [2., 17.]
4 cov = [[10., 0.],
5 [0., 4.]]
----> 7 mkf_internal.plot_3d_covariance(mean, cov)
File [~/work/Kalman-and-Bayesian-Filters-in-Python/kf_book/mkf_internal.py:283](/user/jan/lab/tree/Kalman-and-Bayesian-Filters-in-Python/Kalman-and-Bayesian-Filters-in-Python/kf_book/mkf_internal.py#line=282), in plot_3d_covariance(mean, cov)
280 ys = np.arange(miny, maxy, (maxy-miny)[/40.](/40.))
281 xv, yv = np.meshgrid(xs, ys)
--> 283 zs = np.array([100.* stats.multivariate_gaussian(np.array([x, y]), mean, cov) \
284 for x, y in zip(np.ravel(xv), np.ravel(yv))])
285 zv = zs.reshape(xv.shape)
287 fig = plt.figure()
File [/opt/conda/lib/python3.12/site-packages/filterpy/stats/stats.py:382](/opt/conda/lib/python3.12/site-packages/filterpy/stats/stats.py#line=381), in multivariate_gaussian(x, mu, cov)
380 # force all to numpy.array type, and flatten in case they are vectors
381 x = np.array(x, copy=False, ndmin=1).flatten()
--> 382 mu = np.array(mu, copy=False, ndmin=1).flatten()
384 nx = len(mu)
385 cov = _to_cov(cov, nx)
ValueError: Unable to avoid copy while creating an array as requested.
If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.
``
Metadata
Metadata
Assignees
Labels
No labels