MCPcopy Index your code
hub / github.com/pydata/xarray / _unary_op

Method _unary_op

xarray/core/dataarray.py:4888–4901  ·  view source on GitHub ↗
(self, f: Callable, *args, **kwargs)

Source from the content-addressed store, hash-verified

4886 return computation.dot(other, self)
4887
4888 def _unary_op(self, f: Callable, *args, **kwargs) -> Self:
4889 keep_attrs = kwargs.pop("keep_attrs", None)
4890 if keep_attrs is None:
4891 keep_attrs = _get_keep_attrs(default=True)
4892 with warnings.catch_warnings():
4893 warnings.filterwarnings("ignore", r"All-NaN (slice|axis) encountered")
4894 warnings.filterwarnings(
4895 "ignore", r"Mean of empty slice", category=RuntimeWarning
4896 )
4897 with np.errstate(all="ignore"):
4898 da = self.__array_wrap__(f(self.variable.data, *args, **kwargs))
4899 if keep_attrs:
4900 da.attrs = self.attrs
4901 return da
4902
4903 def _binary_op(
4904 self, other: DaCompatible, f: Callable, reflexive: bool = False

Callers

nothing calls this directly

Calls 3

__array_wrap__Method · 0.95
_get_keep_attrsFunction · 0.90
fFunction · 0.70

Tested by

no test coverage detected