From e52efca5accf06016ca4c1b180216e66db881ce2 Mon Sep 17 00:00:00 2001 From: Konrad Kapp Date: Sat, 20 May 2017 12:50:15 +0200 Subject: BUG: set default type for empty index array to `numpy.intp` (#9142) Fixes #9137 --- numpy/lib/tests/test_arraysetops.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'numpy/lib/tests/test_arraysetops.py') diff --git a/numpy/lib/tests/test_arraysetops.py b/numpy/lib/tests/test_arraysetops.py index fa664ff24..d47534f82 100644 --- a/numpy/lib/tests/test_arraysetops.py +++ b/numpy/lib/tests/test_arraysetops.py @@ -355,6 +355,16 @@ class TestUnique(TestCase): a2, a2_inv = np.unique(a, return_inverse=True) assert_array_equal(a2_inv, np.zeros(5)) + # test for ticket #9137 + a = [] + a1_idx = np.unique(a, return_index=True)[1] + a2_inv = np.unique(a, return_inverse=True)[1] + a3_idx, a3_inv = np.unique(a, return_index=True, return_inverse=True)[1:] + assert_equal(a1_idx.dtype, np.intp) + assert_equal(a2_inv.dtype, np.intp) + assert_equal(a3_idx.dtype, np.intp) + assert_equal(a3_inv.dtype, np.intp) + def test_unique_axis_errors(self): assert_raises(TypeError, self._run_axis_tests, object) assert_raises(TypeError, self._run_axis_tests, -- cgit v1.2.1