|
1 | 1 | import datetime
|
2 | 2 | import functools
|
| 3 | +import warnings |
3 | 4 | from numbers import Number
|
4 | 5 | from typing import (
|
5 | 6 | TYPE_CHECKING,
|
@@ -1583,9 +1584,7 @@ def swap_dims(self, dims_dict: Mapping[Hashable, Hashable]) -> "DataArray":
|
1583 | 1584 | --------
|
1584 | 1585 |
|
1585 | 1586 | >>> arr = xr.DataArray(
|
1586 |
| - ... data=[0, 1], |
1587 |
| - ... dims="x", |
1588 |
| - ... coords={"x": ["a", "b"], "y": ("x", [0, 1])}, |
| 1587 | + ... data=[0, 1], dims="x", coords={"x": ["a", "b"], "y": ("x", [0, 1])}, |
1589 | 1588 | ... )
|
1590 | 1589 | >>> arr
|
1591 | 1590 | <xarray.DataArray (x: 2)>
|
@@ -2709,8 +2708,13 @@ def __rmatmul__(self, other):
|
2709 | 2708 | def _unary_op(f: Callable[..., Any]) -> Callable[..., "DataArray"]:
|
2710 | 2709 | @functools.wraps(f)
|
2711 | 2710 | def func(self, *args, **kwargs):
|
2712 |
| - with np.errstate(all="ignore"): |
2713 |
| - return self.__array_wrap__(f(self.variable.data, *args, **kwargs)) |
| 2711 | + with warnings.catch_warnings(): |
| 2712 | + warnings.filterwarnings("ignore", r"All-NaN (slice|axis) encountered") |
| 2713 | + warnings.filterwarnings( |
| 2714 | + "ignore", r"Mean of empty slice", category=RuntimeWarning |
| 2715 | + ) |
| 2716 | + with np.errstate(all="ignore"): |
| 2717 | + return self.__array_wrap__(f(self.variable.data, *args, **kwargs)) |
2714 | 2718 |
|
2715 | 2719 | return func
|
2716 | 2720 |
|
@@ -3424,9 +3428,7 @@ def map_blocks(
|
3424 | 3428 | to the function being applied in ``xr.map_blocks()``:
|
3425 | 3429 |
|
3426 | 3430 | >>> array.map_blocks(
|
3427 |
| - ... calculate_anomaly, |
3428 |
| - ... kwargs={"groupby_type": "time.year"}, |
3429 |
| - ... template=array, |
| 3431 | + ... calculate_anomaly, kwargs={"groupby_type": "time.year"}, template=array, |
3430 | 3432 | ... ) # doctest: +ELLIPSIS
|
3431 | 3433 | <xarray.DataArray (time: 24)>
|
3432 | 3434 | dask.array<calculate_anomaly-...-<this, shape=(24,), dtype=float64, chunksize=(24,), chunktype=numpy.ndarray>
|
|
0 commit comments