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

Function test_multi_index_propagation

xarray/tests/test_groupby.py:165–181  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

163
164@requires_pandas_ge_2_2
165def test_multi_index_propagation() -> None:
166 # regression test for GH9648
167 times = pd.date_range("2023-01-01", periods=4)
168 locations = ["A", "B"]
169 data = [[0.5, 0.7], [0.6, 0.5], [0.4, 0.6], [0.4, 0.9]]
170
171 da = xr.DataArray(
172 data, dims=["time", "location"], coords={"time": times, "location": locations}
173 )
174 da = da.stack(multiindex=["time", "location"])
175 grouped = da.groupby("multiindex")
176
177 with xr.set_options(use_flox=True):
178 actual = grouped.sum()
179 with xr.set_options(use_flox=False):
180 expected = grouped.first()
181 assert_identical(actual, expected)
182
183
184def test_groupby_da_datetime() -> None:

Callers

nothing calls this directly

Calls 5

stackMethod · 0.95
groupbyMethod · 0.95
assert_identicalFunction · 0.90
firstMethod · 0.80
sumMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…