TST/COMPAT: update GeometryArray getitem error type + fix tests (#2219)

* TST/COMPAT: update GeometryArray getitem error type + fix tests

* fix doctest for GEOS 3.10
This commit is contained in:
Joris Van den Bossche
2021-11-11 23:49:12 +00:00
committed by GitHub
parent 9a1509476a
commit 17fe21ed15
2 changed files with 19 additions and 4 deletions
+7 -4
View File
@@ -363,10 +363,12 @@ class GeometryArray(ExtensionArray):
# for pandas >= 1.0, validate and convert IntegerArray/BooleanArray
# to numpy array, pass-through non-array-like indexers
idx = pd.api.indexers.check_array_indexer(self, idx)
if isinstance(idx, (Iterable, slice)):
return GeometryArray(self.data[idx], crs=self.crs)
else:
raise TypeError("Index type not supported", idx)
if isinstance(idx, (Iterable, slice)):
return GeometryArray(self.data[idx], crs=self.crs)
else:
raise TypeError("Index type not supported", idx)
def __setitem__(self, key, value):
if compat.PANDAS_GE_10:
@@ -740,8 +742,9 @@ class GeometryArray(ExtensionArray):
>>> a = a.to_crs(3857)
>>> to_wkt(a)
array(['POINT (111319 111325)', 'POINT (222639 222684)',
'POINT (333958 334111)'], dtype=object)
array(['POINT (111319.490793 111325.142866)',
'POINT (222638.981587 222684.208506)',
'POINT (333958.47238 334111.171402)'], dtype=object)
>>> a.crs # doctest: +SKIP
<Projected CRS: EPSG:3857>
Name: WGS 84 / Pseudo-Mercator
+12
View File
@@ -231,6 +231,18 @@ def as_array(request):
return request.param
@pytest.fixture
def invalid_scalar(data):
"""
A scalar that *cannot* be held by this ExtensionArray.
The default should work for most subclasses, but is not guaranteed.
If the array can hold any item (i.e. object dtype), then use pytest.skip.
"""
return object.__new__(object)
# Fixtures defined in pandas/conftest.py that are also needed: defining them
# here instead of importing for compatibility