Skip to content

Commit cc55688

Browse files
committed
TST: Adds test for uint64 handling in factorize
1 parent f174869 commit cc55688

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pandas/tests/test_algos.py

+17
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,23 @@ def test_complex_sorting(self):
287287

288288
self.assertRaises(TypeError, algos.factorize, x17[::-1], sort=True)
289289

290+
def test_uint64_factorize(self):
291+
data = np.array([2**63, 1, 2**63], dtype=np.uint64)
292+
exp_labels = np.array([0, 1, 0], dtype=np.intp)
293+
exp_uniques = np.array([2**63, 1], dtype=np.uint64)
294+
295+
labels, uniques = algos.factorize(data)
296+
tm.assert_numpy_array_equal(labels, exp_labels)
297+
tm.assert_numpy_array_equal(uniques, exp_uniques)
298+
299+
data = np.array([2**63, -1, 2**63], dtype=object)
300+
exp_labels = np.array([0, 1, 0], dtype=np.intp)
301+
exp_uniques = np.array([2**63, -1], dtype=object)
302+
303+
labels, uniques = algos.factorize(data)
304+
tm.assert_numpy_array_equal(labels, exp_labels)
305+
tm.assert_numpy_array_equal(uniques, exp_uniques)
306+
290307

291308
class TestUnique(tm.TestCase):
292309
_multiprocess_can_split_ = True

0 commit comments

Comments
 (0)