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

Method test_broadcast_equals

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

Source from the content-addressed store, hash-verified

4690 ),
4691 )
4692 def test_broadcast_equals(self, unit, dtype):
4693 # TODO: does this use indexes?
4694 left_array1 = np.ones(shape=(2, 3), dtype=dtype) * unit_registry.m
4695 left_array2 = np.zeros(shape=(3, 6), dtype=dtype) * unit_registry.m
4696
4697 right_array1 = np.ones(shape=(2,)) * unit
4698 right_array2 = np.zeros(shape=(3,)) * unit
4699
4700 left = xr.Dataset(
4701 {"a": (("x", "y"), left_array1), "b": (("y", "z"), left_array2)},
4702 )
4703 right = xr.Dataset({"a": ("x", right_array1), "b": ("y", right_array2)})
4704
4705 units = merge_mappings(
4706 extract_units(left),
4707 {} if is_compatible(left_array1, unit) else {"a": None, "b": None},
4708 )
4709 expected = is_compatible(left_array1, unit) and strip_units(
4710 left
4711 ).broadcast_equals(strip_units(convert_units(right, units)))
4712 actual = left.broadcast_equals(right)
4713
4714 assert expected == actual
4715
4716 def test_pad(self, dtype):
4717 a = np.linspace(0, 5, 10).astype(dtype) * unit_registry.Pa

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected