@@ -95,29 +95,32 @@ def test_basic(self):
95
95
exp = np .array (["a" , "b" , "c" ], dtype = object )
96
96
tm .assert_numpy_array_equal (uniques , exp )
97
97
98
- codes , uniques = algos .factorize (list (reversed (range (5 ))))
98
+ arr = np .arange (5 , dtype = np .intp )[::- 1 ]
99
+
100
+ codes , uniques = algos .factorize (arr )
99
101
exp = np .array ([0 , 1 , 2 , 3 , 4 ], dtype = np .intp )
100
102
tm .assert_numpy_array_equal (codes , exp )
101
- exp = np .array ([4 , 3 , 2 , 1 , 0 ], dtype = np . int32 )
103
+ exp = np .array ([4 , 3 , 2 , 1 , 0 ], dtype = arr . dtype )
102
104
tm .assert_numpy_array_equal (uniques , exp )
103
105
104
- codes , uniques = algos .factorize (list (reversed (range (5 ))), sort = True )
105
-
106
+ codes , uniques = algos .factorize (arr , sort = True )
106
107
exp = np .array ([4 , 3 , 2 , 1 , 0 ], dtype = np .intp )
107
108
tm .assert_numpy_array_equal (codes , exp )
108
- exp = np .array ([0 , 1 , 2 , 3 , 4 ], dtype = np . int32 )
109
+ exp = np .array ([0 , 1 , 2 , 3 , 4 ], dtype = arr . dtype )
109
110
tm .assert_numpy_array_equal (uniques , exp )
110
111
111
- codes , uniques = algos .factorize (list (reversed (np .arange (5.0 ))))
112
+ arr = np .arange (5.0 )[::- 1 ]
113
+
114
+ codes , uniques = algos .factorize (arr )
112
115
exp = np .array ([0 , 1 , 2 , 3 , 4 ], dtype = np .intp )
113
116
tm .assert_numpy_array_equal (codes , exp )
114
- exp = np .array ([4.0 , 3.0 , 2.0 , 1.0 , 0.0 ], dtype = np . float64 )
117
+ exp = np .array ([4.0 , 3.0 , 2.0 , 1.0 , 0.0 ], dtype = arr . dtype )
115
118
tm .assert_numpy_array_equal (uniques , exp )
116
119
117
- codes , uniques = algos .factorize (list ( reversed ( np . arange ( 5.0 ))) , sort = True )
120
+ codes , uniques = algos .factorize (arr , sort = True )
118
121
exp = np .array ([4 , 3 , 2 , 1 , 0 ], dtype = np .intp )
119
122
tm .assert_numpy_array_equal (codes , exp )
120
- exp = np .array ([0.0 , 1.0 , 2.0 , 3.0 , 4.0 ], dtype = np . float64 )
123
+ exp = np .array ([0.0 , 1.0 , 2.0 , 3.0 , 4.0 ], dtype = arr . dtype )
121
124
tm .assert_numpy_array_equal (uniques , exp )
122
125
123
126
def test_mixed (self ):
0 commit comments