MCPcopy
hub / github.com/pydata/xarray / _unary_op

Method _unary_op

xarray/core/dataset.py:7715–7728  ·  view source on GitHub ↗
(self, f, *args, **kwargs)

Source from the content-addressed store, hash-verified

7713 return obj
7714
7715 def _unary_op(self, f, *args, **kwargs) -> Self:
7716 variables = {}
7717 keep_attrs = kwargs.pop("keep_attrs", None)
7718 if keep_attrs is None:
7719 keep_attrs = _get_keep_attrs(default=True)
7720 for k, v in self._variables.items():
7721 if k in self._coord_names:
7722 variables[k] = v
7723 else:
7724 variables[k] = f(v, *args, **kwargs)
7725 if keep_attrs:
7726 variables[k]._attrs = v._attrs
7727 attrs = self._attrs if keep_attrs else None
7728 return self._replace_with_new_dims(variables, attrs=attrs)
7729
7730 def _binary_op(self, other, f, reflexive=False, join=None) -> Dataset:
7731 from xarray.core.dataarray import DataArray

Callers

nothing calls this directly

Calls 4

_get_keep_attrsFunction · 0.90
itemsMethod · 0.80
fFunction · 0.70

Tested by

no test coverage detected