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

Method test_stack

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

Source from the content-addressed store, hash-verified

2092 np.testing.assert_allclose(expected, actual)
2093
2094 def test_stack(self, dtype):
2095 array = np.linspace(0, 5, 3 * 10).reshape(3, 10).astype(dtype) * unit_registry.m
2096 variable = xr.Variable(("x", "y"), array)
2097
2098 expected = attach_units(
2099 strip_units(variable).stack(z=("x", "y")), extract_units(variable)
2100 )
2101 actual = variable.stack(z=("x", "y"))
2102
2103 assert_units_equal(expected, actual)
2104 assert_identical(expected, actual)
2105
2106 def test_unstack(self, dtype):
2107 array = np.linspace(0, 5, 3 * 10).astype(dtype) * unit_registry.m

Callers

nothing calls this directly

Calls 9

stackMethod · 0.95
assert_identicalFunction · 0.90
attach_unitsFunction · 0.85
strip_unitsFunction · 0.85
extract_unitsFunction · 0.85
assert_units_equalFunction · 0.85
linspaceMethod · 0.80
astypeMethod · 0.45
stackMethod · 0.45

Tested by

no test coverage detected