From 18d416e5d01fea8be1917197c0079b9d62311812 Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Fri, 7 Jul 2017 06:09:53 -0400 Subject: [PATCH] COMPAT: 32-bit compat for testing of indexers xref #16826 --- pandas/core/indexes/category.py | 4 ++-- pandas/tests/indexes/common.py | 14 ++++++++++++++ pandas/tests/indexes/test_base.py | 11 ----------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/pandas/core/indexes/category.py b/pandas/core/indexes/category.py index d13636e8b43e23..c9e0e3b10875c4 100644 --- a/pandas/core/indexes/category.py +++ b/pandas/core/indexes/category.py @@ -497,7 +497,6 @@ def get_indexer(self, target, method=None, limit=None, tolerance=None): codes = self.categories.get_indexer(target) indexer, _ = self._engine.get_indexer_non_unique(codes) - return _ensure_platform_int(indexer) @Appender(_index_shared_docs['get_indexer_non_unique'] % _index_doc_kwargs) @@ -508,7 +507,8 @@ def get_indexer_non_unique(self, target): target = target.categories codes = self.categories.get_indexer(target) - return self._engine.get_indexer_non_unique(codes) + indexer, missing = self._engine.get_indexer_non_unique(codes) + return _ensure_platform_int(indexer), missing @Appender(_index_shared_docs['_convert_scalar_indexer']) def _convert_scalar_indexer(self, key, kind=None): diff --git a/pandas/tests/indexes/common.py b/pandas/tests/indexes/common.py index a6177104d62731..840e68f196b986 100644 --- a/pandas/tests/indexes/common.py +++ b/pandas/tests/indexes/common.py @@ -132,6 +132,20 @@ def test_reindex_base(self): with tm.assert_raises_regex(ValueError, 'Invalid fill method'): idx.get_indexer(idx, method='invalid') + def test_get_indexer_consistency(self): + # See GH 16819 + for name, index in self.indices.items(): + if isinstance(index, IntervalIndex): + continue + + indexer = index.get_indexer(index[0:2]) + assert isinstance(indexer, np.ndarray) + assert indexer.dtype == np.int_ + + indexer, _ = index.get_indexer_non_unique(index[0:2]) + assert isinstance(indexer, np.ndarray) + assert indexer.dtype == np.int_ + def test_ndarray_compat_properties(self): idx = self.create_index() assert idx.T.equals(idx) diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index 7a81a125467d5f..18dbe6624008a8 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -1131,17 +1131,6 @@ def test_get_indexer_strings(self): with pytest.raises(TypeError): idx.get_indexer(['a', 'b', 'c', 'd'], method='pad', tolerance=2) - def test_get_indexer_consistency(self): - # See GH 16819 - for name, index in self.indices.items(): - indexer = index.get_indexer(index[0:2]) - assert isinstance(indexer, np.ndarray) - assert indexer.dtype == np.intp - - indexer, _ = index.get_indexer_non_unique(index[0:2]) - assert isinstance(indexer, np.ndarray) - assert indexer.dtype == np.intp - def test_get_loc(self): idx = pd.Index([0, 1, 2]) all_methods = [None, 'pad', 'backfill', 'nearest']