(self, other, f, reflexive=False, join=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 |
| 7732 | from xarray.core.datatree import DataTree |
| 7733 | from xarray.core.groupby import GroupBy |
| 7734 | |
| 7735 | if isinstance(other, DataTree | GroupBy): |
| 7736 | return NotImplemented |
| 7737 | align_type = OPTIONS["arithmetic_join"] if join is None else join |
| 7738 | if isinstance(other, DataArray | Dataset): |
| 7739 | self, other = align(self, other, join=align_type, copy=False) |
| 7740 | g = f if not reflexive else lambda x, y: f(y, x) |
| 7741 | ds = self._calculate_binary_op(g, other, join=align_type) |
| 7742 | keep_attrs = _get_keep_attrs(default=True) |
| 7743 | if keep_attrs: |
| 7744 | # Combine attributes from both operands, dropping conflicts |
| 7745 | from xarray.structure.merge import merge_attrs |
| 7746 | |
| 7747 | self_attrs = self.attrs |
| 7748 | other_attrs = getattr(other, "attrs", {}) |
| 7749 | ds.attrs = merge_attrs([self_attrs, other_attrs], "drop_conflicts") |
| 7750 | return ds |
| 7751 | |
| 7752 | def _inplace_binary_op(self, other, f) -> Self: |
| 7753 | from xarray.core.dataarray import DataArray |
nothing calls this directly
no test coverage detected