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

Method test_stack

xarray/tests/test_variable.py:1737–1752  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1735 v.set_dims(["z", "x", "y"], shape=(2, 3, 4))
1736
1737 def test_stack(self):
1738 v = Variable(["x", "y"], [[0, 1], [2, 3]], {"foo": "bar"})
1739 actual = v.stack(z=("x", "y"))
1740 expected = Variable("z", [0, 1, 2, 3], v.attrs)
1741 assert_identical(actual, expected)
1742
1743 actual = v.stack(z=("x",))
1744 expected = Variable(("y", "z"), v.data.T, v.attrs)
1745 assert_identical(actual, expected)
1746
1747 actual = v.stack(z=())
1748 assert_identical(actual, v)
1749
1750 actual = v.stack(X=("x",), Y=("y",)).transpose("X", "Y")
1751 expected = Variable(("X", "Y"), v.data, v.attrs)
1752 assert_identical(actual, expected)
1753
1754 def test_stack_errors(self):
1755 v = Variable(["x", "y"], [[0, 1], [2, 3]], {"foo": "bar"})

Callers

nothing calls this directly

Calls 4

stackMethod · 0.95
VariableClass · 0.90
assert_identicalFunction · 0.90
transposeMethod · 0.45

Tested by

no test coverage detected