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

Function test_groupby_binary_op_regression

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

Source from the content-addressed store, hash-verified

2752
2753
2754def test_groupby_binary_op_regression() -> None:
2755 # regression test for #7797
2756 # monthly timeseries that should return "zero anomalies" everywhere
2757 time = xr.date_range("2023-01-01", "2023-12-31", freq="MS")
2758 data = np.linspace(-1, 1, 12)
2759 x = xr.DataArray(data, coords={"time": time})
2760 clim = xr.DataArray(data, coords={"month": np.arange(1, 13, 1)})
2761
2762 # seems to give the correct result if we use the full x, but not with a slice
2763 x_slice = x.sel(time=["2023-04-01"])
2764
2765 # two typical ways of computing anomalies
2766 anom_gb = x_slice.groupby("time.month") - clim
2767
2768 assert_identical(xr.zeros_like(anom_gb), anom_gb)
2769
2770
2771def test_groupby_multiindex_level() -> None:

Callers

nothing calls this directly

Calls 5

selMethod · 0.95
assert_identicalFunction · 0.90
linspaceMethod · 0.80
arangeMethod · 0.80
groupbyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…