From 8a6ab59881b1574fb283b318c0bc9f892f0a7ba2 Mon Sep 17 00:00:00 2001 From: Giacomo Ferroni Date: Sun, 28 Aug 2016 15:28:28 +0100 Subject: [PATCH] Test for segfault in factorize (gh12666) --- pandas/tests/test_algos.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pandas/tests/test_algos.py b/pandas/tests/test_algos.py index 9543d9bba2a3a..092e02ee261a0 100644 --- a/pandas/tests/test_algos.py +++ b/pandas/tests/test_algos.py @@ -299,6 +299,16 @@ def _test_vector_resize(htable, uniques, dtype, nvals): _test_vector_resize(tbl(), vect(), dtype, 0) _test_vector_resize(tbl(), vect(), dtype, 10) + def test_complex_sorting(self): + # gh 12666 - check no segfault + # Test not valid numpy versions older than 1.11 + if pd._np_version_under1p11: + self.skipTest("Test valid only for numpy 1.11+") + + x17 = np.array([complex(i) for i in range(17)], dtype=object) + + self.assertRaises(TypeError, algos.factorize, x17[::-1], sort=True) + class TestUnique(tm.TestCase): _multiprocess_can_split_ = True