(self, other)
| 3055 | |
| 3056 | |
| 3057 | def _broadcast_compat_data(self, other): |
| 3058 | if not OPTIONS["arithmetic_broadcast"] and ( |
| 3059 | (isinstance(other, Variable) and self.dims != other.dims) |
| 3060 | or (is_duck_array(other) and self.ndim != other.ndim) |
| 3061 | ): |
| 3062 | raise ValueError( |
| 3063 | "Broadcasting is necessary but automatic broadcasting is disabled via " |
| 3064 | "global option `'arithmetic_broadcast'`. " |
| 3065 | "Use `xr.set_options(arithmetic_broadcast=True)` to enable automatic broadcasting." |
| 3066 | ) |
| 3067 | |
| 3068 | if all(hasattr(other, attr) for attr in ["dims", "data", "shape", "encoding"]): |
| 3069 | # `other` satisfies the necessary Variable API for broadcast_variables |
| 3070 | new_self, new_other = _broadcast_compat_variables(self, other) |
| 3071 | self_data = new_self.data |
| 3072 | other_data = new_other.data |
| 3073 | dims = new_self.dims |
| 3074 | else: |
| 3075 | # rely on numpy broadcasting rules |
| 3076 | self_data = self.data |
| 3077 | other_data = other |
| 3078 | dims = self.dims |
| 3079 | return self_data, other_data, dims |
| 3080 | |
| 3081 | |
| 3082 | def concat( |
no test coverage detected
searching dependent graphs…