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

Method _inplace_binary_op

xarray/core/dataset.py:7752–7774  ·  view source on GitHub ↗
(self, other, f)

Source from the content-addressed store, hash-verified

7750 return ds
7751
7752 def _inplace_binary_op(self, other, f) -> Self:
7753 from xarray.core.dataarray import DataArray
7754 from xarray.core.groupby import GroupBy
7755
7756 if isinstance(other, GroupBy):
7757 raise TypeError(
7758 "in-place operations between a Dataset and "
7759 "a grouped object are not permitted"
7760 )
7761 # we don't actually modify arrays in-place with in-place Dataset
7762 # arithmetic -- this lets us automatically align things
7763 if isinstance(other, DataArray | Dataset):
7764 other = other.reindex_like(self, copy=False)
7765 g = ops.inplace_to_noninplace_op(f)
7766 ds = self._calculate_binary_op(g, other, inplace=True)
7767 self._replace_with_new_dims(
7768 ds._variables,
7769 ds._coord_names,
7770 attrs=ds._attrs,
7771 indexes=ds._indexes,
7772 inplace=True,
7773 )
7774 return self
7775
7776 def _calculate_binary_op(
7777 self, f, other, join="inner", inplace: bool = False

Callers

nothing calls this directly

Calls 3

_calculate_binary_opMethod · 0.95
reindex_likeMethod · 0.45

Tested by

no test coverage detected