MCPcopy Index your code
hub / github.com/pydata/xarray / test_groupby_da_datetime

Function test_groupby_da_datetime

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

Source from the content-addressed store, hash-verified

182
183
184def test_groupby_da_datetime() -> None:
185 # test groupby with a DataArray of dtype datetime for GH1132
186 # create test data
187 times = pd.date_range("2000-01-01", periods=4)
188 foo = xr.DataArray([1, 2, 3, 4], coords=dict(time=times), dims="time")
189 # create test index
190 reference_dates = [times[0], times[2]]
191 labels = reference_dates[0:1] * 2 + reference_dates[1:2] * 2
192 ind = xr.DataArray(
193 labels, coords=dict(time=times), dims="time", name="reference_date"
194 )
195 g = foo.groupby(ind)
196 actual = g.sum(dim="time")
197 expected = xr.DataArray(
198 [3, 7], coords=dict(reference_date=reference_dates), dims="reference_date"
199 )
200 assert_equal(expected, actual)
201
202
203def test_groupby_duplicate_coordinate_labels() -> None:

Callers

nothing calls this directly

Calls 3

groupbyMethod · 0.95
assert_equalFunction · 0.90
sumMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…