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

Method test_resample_min_count

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

Source from the content-addressed store, hash-verified

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)
2430 ds = Dataset(
2431 {
2432 "foo": (["time", "x", "y"], np.random.randn(10, 5, 3)),
2433 "bar": ("time", np.random.randn(10), {"meta": "data"}),
2434 "time": times,
2435 }
2436 )
2437 # inject nan
2438 ds["foo"] = xr.where(ds["foo"] > 2.0, np.nan, ds["foo"])
2439
2440 actual = ds.resample(time="1D").sum(min_count=1)
2441 expected = xr.concat(
2442 [
2443 ds.isel(time=slice(i * 4, (i + 1) * 4)).sum("time", min_count=1)
2444 for i in range(3)
2445 ],
2446 dim=actual["time"],
2447 data_vars="all",
2448 )
2449 assert_allclose(expected, actual)
2450
2451 def test_resample_by_mean_with_keep_attrs(self) -> None:
2452 times = pd.date_range("2000-01-01", freq="6h", periods=10)

Callers

nothing calls this directly

Calls 7

resampleMethod · 0.95
iselMethod · 0.95
DatasetClass · 0.90
assert_allcloseFunction · 0.90
whereMethod · 0.45
sumMethod · 0.45
concatMethod · 0.45

Tested by

no test coverage detected