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

Method test_broadcast_equals

xarray/tests/test_units.py:3152–3168  ·  view source on GitHub ↗
(self, unit, dtype)

Source from the content-addressed store, hash-verified

3150 ),
3151 )
3152 def test_broadcast_equals(self, unit, dtype):
3153 left_array = np.ones(shape=(2, 2), dtype=dtype) * unit_registry.m
3154 right_array = np.ones(shape=(2,), dtype=dtype) * unit
3155
3156 left = xr.DataArray(data=left_array, dims=("x", "y"))
3157 right = xr.DataArray(data=right_array, dims="x")
3158
3159 units = {
3160 **extract_units(left),
3161 **({} if left_array.check(unit) else {None: None}),
3162 }
3163 expected = strip_units(left).broadcast_equals(
3164 strip_units(convert_units(right, units))
3165 ) & left_array.check(unit)
3166 actual = left.broadcast_equals(right)
3167
3168 assert expected == actual
3169
3170 def test_pad(self, dtype):
3171 array = np.linspace(0, 5, 10).astype(dtype) * unit_registry.m

Callers

nothing calls this directly

Calls 6

broadcast_equalsMethod · 0.95
extract_unitsFunction · 0.85
strip_unitsFunction · 0.85
convert_unitsFunction · 0.85
checkMethod · 0.80
broadcast_equalsMethod · 0.45

Tested by

no test coverage detected