@@ -807,6 +807,25 @@ def test_groupby_math_more() -> None:
807
807
ds + ds .groupby ("time.month" )
808
808
809
809
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
+
810
829
@pytest .mark .parametrize ("indexed_coord" , [True , False ])
811
830
def test_groupby_bins_math (indexed_coord ) -> None :
812
831
N = 7
@@ -2181,6 +2200,3 @@ def test_resample_cumsum(method: str, expected_array: list[float]) -> None:
2181
2200
actual = getattr (ds .foo .resample (time = "3M" ), method )(dim = "time" )
2182
2201
expected .coords ["time" ] = ds .time
2183
2202
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