@@ -329,3 +329,40 @@ def test_cython_group_sum_Inf_at_beginning_and_end(values, out):
329329 actual ,
330330 expected ,
331331 )
332+
333+
334+ @pytest .mark .parametrize (
335+ "values, expected_values" ,
336+ [
337+ (np .finfo (np .float64 ).max , [[np .inf ]]),
338+ (np .finfo (np .float64 ).min , [[- np .inf ]]),
339+ (
340+ np .complex128 (np .finfo (np .float64 ).min , np .finfo (np .float64 ).max ),
341+ [[np .complex128 (- np .inf , np .inf )]],
342+ ),
343+ (
344+ np .complex128 (np .finfo (np .float64 ).max , np .finfo (np .float64 ).min ),
345+ [[np .complex128 (np .inf , - np .inf )]],
346+ ),
347+ (
348+ np .complex128 (np .finfo (np .float64 ).max , np .finfo (np .float64 ).max ),
349+ [[np .complex128 (np .inf , np .inf )]],
350+ ),
351+ (
352+ np .complex128 (np .finfo (np .float64 ).min , np .finfo (np .float64 ).min ),
353+ [[np .complex128 (- np .inf , - np .inf )]],
354+ ),
355+ ],
356+ )
357+ def test_cython_group_sum_overflow (values , expected_values ):
358+ # GH-60303
359+ data = np .array ([[values ] for _ in range (3 )])
360+ labels = np .array ([0 , 0 , 0 ], dtype = np .intp )
361+ counts = np .array ([0 ], dtype = "int64" )
362+
363+ expected = np .array (expected_values , dtype = values .dtype )
364+ actual = np .zeros_like (expected )
365+
366+ group_sum (actual , counts , data , labels , None , is_datetimelike = False )
367+
368+ tm .assert_numpy_array_equal (actual , expected )
0 commit comments