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

Method test_to_unstacked_dataset

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

Source from the content-addressed store, hash-verified

3661
3662 @pytest.mark.skip(reason="indexes don't support units")
3663 def test_to_unstacked_dataset(self, dtype):
3664 array = (
3665 np.linspace(0, 10, 5 * 10).reshape(5, 10).astype(dtype)
3666 * unit_registry.pascal
3667 )
3668 x = np.arange(array.shape[0]) * unit_registry.m
3669 y = np.arange(array.shape[1]) * unit_registry.s
3670
3671 data_array = xr.DataArray(
3672 data=array, coords={"x": x, "y": y}, dims=("x", "y")
3673 ).stack(z=("x", "y"))
3674
3675 func = method("to_unstacked_dataset", dim="z")
3676
3677 expected = attach_units(
3678 func(strip_units(data_array)),
3679 {
3680 "y": y.units,
3681 **dict(zip(x.magnitude, [array.units] * len(y), strict=True)),
3682 },
3683 ).rename({elem.magnitude: elem for elem in x})
3684 actual = func(data_array)
3685
3686 assert_units_equal(expected, actual)
3687 assert_identical(expected, actual)
3688
3689 @pytest.mark.parametrize(
3690 "func",

Callers

nothing calls this directly

Calls 11

assert_identicalFunction · 0.90
methodClass · 0.85
attach_unitsFunction · 0.85
strip_unitsFunction · 0.85
assert_units_equalFunction · 0.85
linspaceMethod · 0.80
arangeMethod · 0.80
funcFunction · 0.70
astypeMethod · 0.45
stackMethod · 0.45
renameMethod · 0.45

Tested by

no test coverage detected