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

Method test_assign_new_multiindex

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

Source from the content-addressed store, hash-verified

5055 data.assign_coords(level_1=range(4))
5056
5057 def test_assign_new_multiindex(self) -> None:
5058 midx = pd.MultiIndex.from_arrays([["a", "a", "b", "b"], [0, 1, 0, 1]])
5059 midx_coords = Coordinates.from_pandas_multiindex(midx, "x")
5060
5061 ds = Dataset(coords={"x": [1, 2]})
5062 expected = Dataset(coords=midx_coords)
5063
5064 with pytest.warns(
5065 FutureWarning,
5066 match=r".*`pandas.MultiIndex`.*no longer be implicitly promoted.*",
5067 ):
5068 actual = ds.assign(x=midx)
5069 assert_identical(actual, expected)
5070
5071 @pytest.mark.parametrize("orig_coords", [{}, {"x": range(4)}])
5072 def test_assign_coords_new_multiindex(self, orig_coords) -> None:

Callers

nothing calls this directly

Calls 4

assignMethod · 0.95
DatasetClass · 0.90
assert_identicalFunction · 0.90

Tested by

no test coverage detected