Skip to content
forked from pydata/xarray

Commit e798786

Browse files
committed
Add regression test for pydata#7601
Closes pydata#7601
1 parent 3f4dde2 commit e798786

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

xarray/tests/test_groupby.py

+19-3
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,25 @@ def test_groupby_math_more() -> None:
807807
ds + ds.groupby("time.month")
808808

809809

810+
@pytest.mark.parametrize("use_flox", [True, False])
811+
def test_groupby_bins_cut_kwargs(use_flox):
812+
da = xr.DataArray(np.arange(12).reshape(6, 2), dims=("x", "y"))
813+
x_bins = (0, 2, 4, 6)
814+
815+
with xr.set_options(use_flox=use_flox):
816+
actual = da.groupby_bins(
817+
"x", bins=x_bins, include_lowest=True, right=False
818+
).mean()
819+
expected = xr.DataArray(
820+
np.array([[1.0, 2.0], [5.0, 6.0], [9.0, 10.0]]),
821+
dims=("x_bins", "y"),
822+
coords={
823+
"x_bins": ("x_bins", pd.IntervalIndex.from_breaks(x_bins, closed="left"))
824+
},
825+
)
826+
assert_identical(expected, actual)
827+
828+
810829
@pytest.mark.parametrize("indexed_coord", [True, False])
811830
def test_groupby_bins_math(indexed_coord) -> None:
812831
N = 7
@@ -2181,6 +2200,3 @@ def test_resample_cumsum(method: str, expected_array: list[float]) -> None:
21812200
actual = getattr(ds.foo.resample(time="3M"), method)(dim="time")
21822201
expected.coords["time"] = ds.time
21832202
assert_identical(expected.drop_vars(["time"]).foo, actual)
2184-
2185-
2186-
# TODO: move other groupby tests from test_dataset and test_dataarray over here

0 commit comments

Comments
 (0)