@@ -527,9 +527,23 @@ def test_types_quantile() -> None:
527527 df .quantile (np .array ([0.25 , 0.75 ]))
528528
529529
530- def test_types_clip () -> None :
530+ @pytest .mark .parametrize ("lower" , [None , 5 , pd .Series ([3 , 4 ])])
531+ @pytest .mark .parametrize ("upper" , [None , 15 , pd .Series ([12 , 13 ])])
532+ @pytest .mark .parametrize ("axis" , [None , 0 , "index" ])
533+ def test_types_clip (lower , upper , axis ) -> None :
534+ def is_none_or_numeric (val : Any ) -> bool :
535+ return val is None or isinstance (val , int | float )
536+
531537 df = pd .DataFrame (data = {"col1" : [20 , 12 ], "col2" : [3 , 14 ]})
532- df .clip (lower = 5 , upper = 15 )
538+ uses_array = not (is_none_or_numeric (lower ) and is_none_or_numeric (upper ))
539+ if uses_array and axis is None :
540+ with pytest .raises (ValueError ):
541+ df .clip (lower = lower , upper = upper , axis = axis )
542+ else :
543+ check (
544+ assert_type (df .clip (lower = lower , upper = upper , axis = axis ), pd .DataFrame ),
545+ pd .DataFrame ,
546+ )
533547
534548
535549def test_types_abs () -> None :
0 commit comments