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

Function _broadcast_compat_data

xarray/core/variable.py:3057–3079  ·  view source on GitHub ↗
(self, other)

Source from the content-addressed store, hash-verified

3055
3056
3057def _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
3082def concat(

Callers 2

_binary_opMethod · 0.85
_inplace_binary_opMethod · 0.85

Calls 2

is_duck_arrayFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…