Skip to content

Commit

Permalink
COMPAT: 32-bit compat for testing of indexers
Browse files Browse the repository at this point in the history
  • Loading branch information
jreback committed Jul 7, 2017
1 parent 8d197ba commit 18d416e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions pandas/core/indexes/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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):
Expand Down
14 changes: 14 additions & 0 deletions pandas/tests/indexes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 0 additions & 11 deletions pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down

0 comments on commit 18d416e

Please sign in to comment.