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

Method test_resample_and_first

xarray/tests/test_groupby.py:2402–2426  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2400 reverse.resample(time=resample_freq).mean()
2401
2402 def test_resample_and_first(self) -> None:
2403 times = pd.date_range("2000-01-01", freq="6h", periods=10)
2404 ds = Dataset(
2405 {
2406 "foo": (["time", "x", "y"], np.random.randn(10, 5, 3)),
2407 "bar": ("time", np.random.randn(10), {"meta": "data"}),
2408 "time": times,
2409 }
2410 )
2411
2412 actual = ds.resample(time="1D").first(keep_attrs=True)
2413 expected = ds.isel(time=[0, 4, 8])
2414 assert_identical(expected, actual)
2415
2416 # upsampling
2417 expected_time = pd.date_range("2000-01-01", freq="3h", periods=19)
2418 expected = ds.reindex(time=expected_time)
2419 rs = ds.resample(time="3h")
2420 for how in ["mean", "sum", "first", "last"]:
2421 method = getattr(rs, how)
2422 result = method()
2423 assert_equal(expected, result)
2424 for method in [np.mean]:
2425 result = rs.reduce(method)
2426 assert_equal(expected, result)
2427
2428 def test_resample_min_count(self) -> None:
2429 times = pd.date_range("2000-01-01", freq="6h", periods=10)

Callers

nothing calls this directly

Calls 9

resampleMethod · 0.95
iselMethod · 0.95
reindexMethod · 0.95
DatasetClass · 0.90
assert_identicalFunction · 0.90
assert_equalFunction · 0.90
methodClass · 0.85
firstMethod · 0.80
reduceMethod · 0.45

Tested by

no test coverage detected