(self)
| 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( |
nothing calls this directly
no test coverage detected