Skip to content

Commit

Permalink
TST: Add comment and test for geopandas compat fix (GH27259) (pandas-…
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisvandenbossche authored and TomAugspurger committed Jul 8, 2019
1 parent 3c78b2f commit c64c9cb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ def __getitem__(self, key):
# generally slice or list.
# TODO(ix): most/all of the TypeError cases here are for ix,
# so this check can be removed once ix is removed.
# The InvalidIndexError is only catched for compatibility
# with geopandas, see
# https://github.com/pandas-dev/pandas/issues/27258
pass
else:
if is_scalar(values):
Expand Down
22 changes: 21 additions & 1 deletion pandas/tests/test_downstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from pandas.compat import PY36

from pandas import DataFrame
from pandas import DataFrame, Series
from pandas.util import testing as tm


Expand Down Expand Up @@ -123,6 +123,26 @@ def test_geopandas():
assert geopandas.read_file(fp) is not None


def test_geopandas_coordinate_indexer():
# this test is included to have coverage of one case in the indexing.py
# code that is only kept for compatibility with geopandas, see
# https://github.com/pandas-dev/pandas/issues/27258
# We should be able to remove this after some time when its usage is
# removed in geopandas
from pandas.core.indexing import _NDFrameIndexer

class _CoordinateIndexer(_NDFrameIndexer):
def _getitem_tuple(self, tup):
obj = self.obj
xs, ys = tup
return obj[xs][ys]

Series._create_indexer("cx", _CoordinateIndexer)
s = Series(range(5))
res = s.cx[:, :]
tm.assert_series_equal(s, res)


# Cython import warning
@pytest.mark.filterwarnings("ignore:can't resolve:ImportWarning")
def test_pyarrow(df):
Expand Down

0 comments on commit c64c9cb

Please sign in to comment.