(self, func, dtype)
| 3634 | ids=repr, |
| 3635 | ) |
| 3636 | def test_stacking_stacked(self, func, dtype): |
| 3637 | array = ( |
| 3638 | np.linspace(0, 10, 5 * 10).reshape(5, 10).astype(dtype) * unit_registry.m |
| 3639 | ) |
| 3640 | x = np.arange(array.shape[0]) |
| 3641 | y = np.arange(array.shape[1]) |
| 3642 | |
| 3643 | data_array = xr.DataArray( |
| 3644 | name="data", data=array, coords={"x": x, "y": y}, dims=("x", "y") |
| 3645 | ) |
| 3646 | stacked = data_array.stack(z=("x", "y")) |
| 3647 | |
| 3648 | expected = attach_units(func(strip_units(stacked)), {"data": unit_registry.m}) |
| 3649 | actual = func(stacked) |
| 3650 | |
| 3651 | assert_units_equal(expected, actual) |
| 3652 | # TODO: strip_units/attach_units reconstruct DataArrays from scratch, |
| 3653 | # losing index structure (e.g., MultiIndex from stack becomes regular Index). |
| 3654 | # Fix these utilities to preserve indexes, then remove check_indexes=False. |
| 3655 | if func.name == "reset_index": |
| 3656 | assert_identical( |
| 3657 | expected, actual, check_default_indexes=False, check_indexes=False |
| 3658 | ) |
| 3659 | else: |
| 3660 | assert_identical(expected, actual, check_indexes=False) |
| 3661 | |
| 3662 | @pytest.mark.skip(reason="indexes don't support units") |
| 3663 | def test_to_unstacked_dataset(self, dtype): |
nothing calls this directly
no test coverage detected