You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[6], line 1
----> 1 np.nan_to_num(ds.sst, 0)
File ~/miniforge3/envs/xarray-tutorial-v1/lib/python3.12/site-packages/numpy/lib/_type_check_impl.py:460, in nan_to_num(x, copy, nan, posinf, neginf)
366@array_function_dispatch(_nan_to_num_dispatcher)
367defnan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None):
368"""369 Replace NaN with zero and infinity with large finite numbers (default
370 behaviour) orwith the numbers defined by the user using the `nan`,
(...)
458 array([222222.+111111.j, 111111. +0.j, 111111.+222222.j])
459"""
--> 460 x = _nx.array(x, subok=True, copy=copy)
461 xtype = x.dtype.type
463 isscalar = (x.ndim ==0)
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.
Seen upgrading package versions (#270) if numpy>=2 in environment
The text was updated successfully, but these errors were encountered:
Looks like the tutorial code should just use named keywords instead of positional
np.nan_to_num(ds.sst, 0) is actually intended to be np.nan_to_num(ds.sst, nan=0) but according to the docstring order is actually setting copy=0 (copy=False):
https://tutorial.xarray.dev/fundamentals/03.1_computation_with_xarray.html#applying-arbitrary-functions
Seen upgrading package versions (#270) if numpy>=2 in environment
The text was updated successfully, but these errors were encountered: