Skip to content

Commit 23adaf2

Browse files
committed
fix platform dtype
1 parent 929cc37 commit 23adaf2

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

pandas/tests/test_algos.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -95,29 +95,32 @@ def test_basic(self):
9595
exp = np.array(["a", "b", "c"], dtype=object)
9696
tm.assert_numpy_array_equal(uniques, exp)
9797

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)
99101
exp = np.array([0, 1, 2, 3, 4], dtype=np.intp)
100102
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)
102104
tm.assert_numpy_array_equal(uniques, exp)
103105

104-
codes, uniques = algos.factorize(list(reversed(range(5))), sort=True)
105-
106+
codes, uniques = algos.factorize(arr, sort=True)
106107
exp = np.array([4, 3, 2, 1, 0], dtype=np.intp)
107108
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)
109110
tm.assert_numpy_array_equal(uniques, exp)
110111

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)
112115
exp = np.array([0, 1, 2, 3, 4], dtype=np.intp)
113116
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)
115118
tm.assert_numpy_array_equal(uniques, exp)
116119

117-
codes, uniques = algos.factorize(list(reversed(np.arange(5.0))), sort=True)
120+
codes, uniques = algos.factorize(arr, sort=True)
118121
exp = np.array([4, 3, 2, 1, 0], dtype=np.intp)
119122
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)
121124
tm.assert_numpy_array_equal(uniques, exp)
122125

123126
def test_mixed(self):

0 commit comments

Comments
 (0)