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

Method test_broadcast_equals

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

Source from the content-addressed store, hash-verified

1835 ),
1836 )
1837 def test_broadcast_equals(self, unit, dtype):
1838 base_unit = unit_registry.m
1839 left_array = np.ones(shape=(2, 2), dtype=dtype) * base_unit
1840 value = (
1841 (1 * base_unit).to(unit).magnitude if is_compatible(unit, base_unit) else 1
1842 )
1843 right_array = np.full(shape=(2,), fill_value=value, dtype=dtype) * unit
1844
1845 left = xr.Variable(("x", "y"), left_array)
1846 right = xr.Variable("x", right_array)
1847
1848 units = {
1849 **extract_units(left),
1850 **({} if is_compatible(unit, base_unit) else {None: None}),
1851 }
1852 expected = strip_units(left).broadcast_equals(
1853 strip_units(convert_units(right, units))
1854 ) & is_compatible(unit, base_unit)
1855 actual = left.broadcast_equals(right)
1856
1857 assert expected == actual
1858
1859 @pytest.mark.parametrize("dask", [False, pytest.param(True, marks=[requires_dask])])
1860 @pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 6

broadcast_equalsMethod · 0.95
is_compatibleFunction · 0.85
extract_unitsFunction · 0.85
strip_unitsFunction · 0.85
convert_unitsFunction · 0.85
broadcast_equalsMethod · 0.45

Tested by

no test coverage detected