@@ -856,16 +856,35 @@ def test_map_reduce_blockwise_mixed():
856856
857857
858858@requires_dask
859- @pytest .mark .parametrize ("method" , ["blockwise " , "split-reduce " , "map-reduce" , "cohorts" ])
859+ @pytest .mark .parametrize ("method" , ["split-reduce " , "blockwise " , "map-reduce" , "cohorts" ])
860860def test_group_by_datetime (engine , method ):
861- t = pd .date_range ("2000-01-01" , "2000-12-31" , freq = "D" ).to_series ()
862- data = t .dt .dayofyear
863- actual , _ = groupby_reduce (
864- dask .array .from_array (data .values , chunks = 365 ),
865- t ,
861+ kwargs = dict (
866862 func = "mean" ,
867863 method = method ,
868864 engine = engine ,
869865 )
866+ t = pd .date_range ("2000-01-01" , "2000-12-31" , freq = "D" ).to_series ()
867+ data = t .dt .dayofyear
868+ daskarray = dask .array .from_array (data .values , chunks = 30 )
869+
870+ actual , _ = groupby_reduce (daskarray , t , ** kwargs )
870871 expected = data .to_numpy ().astype (float )
871872 assert_equal (expected , actual )
873+
874+ if method == "blockwise" :
875+ return None
876+
877+ edges = pd .date_range ("1999-12-31" , "2000-12-31" , freq = "M" ).to_series ().to_numpy ()
878+ actual , _ = groupby_reduce (daskarray , t .to_numpy (), isbin = True , expected_groups = edges , ** kwargs )
879+ expected = data .resample ("M" ).mean ().to_numpy ()
880+ assert_equal (expected , actual )
881+
882+ actual , _ = groupby_reduce (
883+ np .broadcast_to (daskarray , (2 , 3 , daskarray .shape [- 1 ])),
884+ t .to_numpy (),
885+ isbin = True ,
886+ expected_groups = edges ,
887+ ** kwargs ,
888+ )
889+ expected = np .broadcast_to (expected , (2 , 3 , expected .shape [- 1 ]))
890+ assert_equal (expected , actual )
0 commit comments