MCPcopy
hub / github.com/pydata/xarray / test_reindex_with_multiindex_level

Method test_reindex_with_multiindex_level

xarray/tests/test_dataset.py:2515–2526  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2513 assert actual.x.dtype == expected.x.dtype
2514
2515 def test_reindex_with_multiindex_level(self) -> None:
2516 # test for https://github.com/pydata/xarray/issues/10347
2517 mindex = pd.MultiIndex.from_product(
2518 [[100, 200, 300], [1, 2, 3, 4]], names=["x", "y"]
2519 )
2520 y_idx = PandasIndex(mindex.levels[1], "y")
2521
2522 ds1 = xr.Dataset(coords={"y": [1, 2, 3]})
2523 ds2 = xr.Dataset(coords=xr.Coordinates.from_xindex(y_idx))
2524
2525 actual = ds1.reindex(y=ds2.y)
2526 assert_identical(actual, ds2)
2527
2528 @pytest.mark.parametrize("fill_value", [dtypes.NA, 2, 2.0, {"foo": 2, "bar": 1}])
2529 def test_align_fill_value(self, fill_value) -> None:

Callers

nothing calls this directly

Calls 4

reindexMethod · 0.95
PandasIndexClass · 0.90
assert_identicalFunction · 0.90
from_xindexMethod · 0.80

Tested by

no test coverage detected