@@ -32,8 +32,9 @@ def test_simple():
3232 tm .assert_numpy_array_equal (result , expected , check_dtype = False )
3333
3434
35- def test_bins ():
36- data = np .array ([0.2 , 1.4 , 2.5 , 6.2 , 9.7 , 2.1 ])
35+ @pytest .mark .parametrize ("func" , [list , np .array ])
36+ def test_bins (func ):
37+ data = func ([0.2 , 1.4 , 2.5 , 6.2 , 9.7 , 2.1 ])
3738 result , bins = cut (data , 3 , retbins = True )
3839
3940 intervals = IntervalIndex .from_breaks (bins .round (3 ))
@@ -68,18 +69,6 @@ def test_no_right():
6869 tm .assert_almost_equal (bins , np .array ([0.2 , 2.575 , 4.95 , 7.325 , 9.7095 ]))
6970
7071
71- def test_array_like ():
72- data = [0.2 , 1.4 , 2.5 , 6.2 , 9.7 , 2.1 ]
73- result , bins = cut (data , 3 , retbins = True )
74-
75- intervals = IntervalIndex .from_breaks (bins .round (3 ))
76- intervals = intervals .take ([0 , 0 , 0 , 1 , 2 , 0 ])
77- expected = Categorical (intervals , ordered = True )
78-
79- tm .assert_categorical_equal (result , expected )
80- tm .assert_almost_equal (bins , np .array ([0.1905 , 3.36666667 , 6.53333333 , 9.7 ]))
81-
82-
8372def test_bins_from_interval_index ():
8473 c = cut (range (5 ), 3 )
8574 expected = c
0 commit comments