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

Method test_stack

xarray/tests/test_sparse.py:670–685  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

668 )
669
670 def test_stack(self):
671 arr = make_xrarray({"w": 2, "x": 3, "y": 4})
672 stacked = arr.stack(z=("x", "y"))
673
674 z = pd.MultiIndex.from_product(
675 [list(range(3)), list(range(4))], names=["x", "y"]
676 )
677
678 expected = xr.DataArray(
679 arr.data.reshape((2, -1)), {"w": [0, 1], "z": z}, dims=["w", "z"]
680 )
681
682 assert_equal(expected, stacked)
683
684 roundtripped = stacked.unstack()
685 assert_identical(arr, roundtripped)
686
687 def test_dataarray_repr(self):
688 a = xr.DataArray(

Callers

nothing calls this directly

Calls 5

assert_equalFunction · 0.90
assert_identicalFunction · 0.90
make_xrarrayFunction · 0.85
stackMethod · 0.45
unstackMethod · 0.45

Tested by

no test coverage detected