(
self, other: DaCompatible, f: Callable, reflexive: bool = False
)
| 4901 | return da |
| 4902 | |
| 4903 | def _binary_op( |
| 4904 | self, other: DaCompatible, f: Callable, reflexive: bool = False |
| 4905 | ) -> Self: |
| 4906 | from xarray.core.datatree import DataTree |
| 4907 | from xarray.core.groupby import GroupBy |
| 4908 | |
| 4909 | if isinstance(other, DataTree | Dataset | GroupBy): |
| 4910 | return NotImplemented |
| 4911 | if isinstance(other, DataArray): |
| 4912 | align_type = OPTIONS["arithmetic_join"] |
| 4913 | self, other = align(self, other, join=align_type, copy=False) |
| 4914 | other_variable_or_arraylike: DaCompatible = getattr(other, "variable", other) |
| 4915 | other_coords = getattr(other, "coords", None) |
| 4916 | |
| 4917 | variable = ( |
| 4918 | f(self.variable, other_variable_or_arraylike) |
| 4919 | if not reflexive |
| 4920 | else f(other_variable_or_arraylike, self.variable) |
| 4921 | ) |
| 4922 | coords, indexes = self.coords._merge_raw( |
| 4923 | other_coords, reflexive, compat=OPTIONS["arithmetic_compat"] |
| 4924 | ) |
| 4925 | name = result_name([self, other]) |
| 4926 | |
| 4927 | return self._replace(variable, coords, name, indexes=indexes) |
| 4928 | |
| 4929 | def _inplace_binary_op(self, other: DaCompatible, f: Callable) -> Self: |
| 4930 | from xarray.core.groupby import GroupBy |
nothing calls this directly
no test coverage detected