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

Method test_to_stacked_array

xarray/tests/test_units.py:4781–4800  ·  view source on GitHub ↗
(self, dtype)

Source from the content-addressed store, hash-verified

4779 reason="stacked dimension's labels have to be hashable, but is a numpy.array"
4780 )
4781 def test_to_stacked_array(self, dtype):
4782 labels = range(5) * unit_registry.s
4783 arrays = {
4784 name: np.linspace(0, 1, 10).astype(dtype) * unit_registry.m
4785 for name in labels
4786 }
4787
4788 ds = xr.Dataset({name: ("x", array) for name, array in arrays.items()})
4789 units = {None: unit_registry.m, "y": unit_registry.s}
4790
4791 func = method("to_stacked_array", "z", variable_dim="y", sample_dims=["x"])
4792
4793 actual = func(ds).rename(None)
4794 expected = attach_units(
4795 func(strip_units(ds)).rename(None),
4796 units,
4797 )
4798
4799 assert_units_equal(expected, actual)
4800 assert_equal(expected, actual)
4801
4802 @pytest.mark.parametrize(
4803 "func",

Callers

nothing calls this directly

Calls 10

assert_equalFunction · 0.90
methodClass · 0.85
attach_unitsFunction · 0.85
strip_unitsFunction · 0.85
assert_units_equalFunction · 0.85
linspaceMethod · 0.80
itemsMethod · 0.80
funcFunction · 0.70
astypeMethod · 0.45
renameMethod · 0.45

Tested by

no test coverage detected