Skip to content

Commit 8fdfa51

Browse files
mralgosjreback
authored andcommitted
Test for segfault in factorize (gh12666) (#14112)
1 parent 5db52f0 commit 8fdfa51

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pandas/tests/test_algos.py

+10
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,16 @@ def _test_vector_resize(htable, uniques, dtype, nvals):
299299
_test_vector_resize(tbl(), vect(), dtype, 0)
300300
_test_vector_resize(tbl(), vect(), dtype, 10)
301301

302+
def test_complex_sorting(self):
303+
# gh 12666 - check no segfault
304+
# Test not valid numpy versions older than 1.11
305+
if pd._np_version_under1p11:
306+
self.skipTest("Test valid only for numpy 1.11+")
307+
308+
x17 = np.array([complex(i) for i in range(17)], dtype=object)
309+
310+
self.assertRaises(TypeError, algos.factorize, x17[::-1], sort=True)
311+
302312

303313
class TestUnique(tm.TestCase):
304314
_multiprocess_can_split_ = True

0 commit comments

Comments
 (0)