Backport upstream PR’s #2219, #2289, #2298, and #2320 in order to resolve test failures with pandas 1.4. It seems that PR#2320 may also be needed for pandas 1.3.5, which should have been a compatible release.
79 lines
2.9 KiB
Diff
79 lines
2.9 KiB
Diff
From ac67515c9df745b672cca1669adf05eaf5cb0f3b Mon Sep 17 00:00:00 2001
|
|
From: Joris Van den Bossche <jorisvandenbossche@gmail.com>
|
|
Date: Sat, 6 Nov 2021 11:20:08 +0100
|
|
Subject: [PATCH 1/2] TST/COMPAT: update GeometryArray getitem error type + fix
|
|
tests
|
|
|
|
---
|
|
geopandas/array.py | 6 ++++--
|
|
geopandas/tests/test_extension_array.py | 12 ++++++++++++
|
|
2 files changed, 16 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/geopandas/array.py b/geopandas/array.py
|
|
index 0532c08b8..3319847ea 100644
|
|
--- a/geopandas/array.py
|
|
+++ b/geopandas/array.py
|
|
@@ -363,10 +363,12 @@ def __getitem__(self, idx):
|
|
# 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:
|
|
diff --git a/geopandas/tests/test_extension_array.py b/geopandas/tests/test_extension_array.py
|
|
index 6e1205b26..9582404b4 100644
|
|
--- a/geopandas/tests/test_extension_array.py
|
|
+++ b/geopandas/tests/test_extension_array.py
|
|
@@ -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
|
|
|
|
|
|
From 7d0de45cd794161c52ee998d3e1e4ac2f683e87b Mon Sep 17 00:00:00 2001
|
|
From: Joris Van den Bossche <jorisvandenbossche@gmail.com>
|
|
Date: Sat, 6 Nov 2021 16:40:22 +0100
|
|
Subject: [PATCH 2/2] fix doctest for GEOS 3.10
|
|
|
|
---
|
|
geopandas/array.py | 5 +++--
|
|
1 file changed, 3 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/geopandas/array.py b/geopandas/array.py
|
|
index 3319847ea..fd7b7fc6f 100644
|
|
--- a/geopandas/array.py
|
|
+++ b/geopandas/array.py
|
|
@@ -742,8 +742,9 @@ def to_crs(self, crs=None, epsg=None):
|
|
|
|
>>> 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
|