nebius/SWE-bench-extra huggingface dataset:
Repository: geopandas/dask-geopandas

Issue:
BUG: preserve spatial_partitions in GeoDataFrame.set_crs
Currently, using `set_crs` doesn't preserve the spatial partitions (similar as `copy`, see https://github.com/geopandas/dask-geopandas/pull/56):

```python
import geopandas
import dask_geopandas

gdf = geopandas.read_file(geopandas.datasets.get_path("naturalearth_lowres"))
# remove the crs for purpose of the reproducible example
gdf.crs = None

# create partitioned dataframe + calculate spatial partitions
ddf = dask_geopandas.from_geopandas(gdf, npartitions=4)
ddf.calculate_spatial_partitions()

>>> ddf.spatial_partitions
0    POLYGON ((-68.149 -55.612, -68.640 -55.580, -6...
1    POLYGON ((18.465 -29.045, 16.345 -28.577, -77....
2    POLYGON ((166.740 -22.400, -8.899 36.869, -9.5...
3    POLYGON ((-180.000 -90.000, -180.000 -84.713, ...
dtype: geometry
>>> ddf = ddf.set_crs("EPSG:4326")
>>> ddf.spatial_partitions is None
True
```

Comments:

Patch:
diff --git a/dask_geopandas/core.py b/dask_geopandas/core.py
index 022be1a..6dea435 100644
--- a/dask_geopandas/core.py
+++ b/dask_geopandas/core.py
@@ -153,9 +153,14 @@ class _Frame(dd.core._Frame, OperatorMethodMixin):
 
     def set_crs(self, value, allow_override=False):
         """Set the value of the crs on a new object"""
-        return self.map_partitions(
+        new = self.map_partitions(
             _set_crs, value, allow_override, enforce_metadata=False
         )
+        if self.spatial_partitions is not None:
+            new.spatial_partitions = self.spatial_partitions.set_crs(
+                value, allow_override=allow_override
+            )
+        return new
 
     def to_crs(self, crs=None, epsg=None):
         token = f"{self._name}-to_crs"


Test patch:
diff --git a/tests/test_core.py b/tests/test_core.py
index f882443..2ff7a94 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -8,7 +8,7 @@ import dask.dataframe as dd
 from dask.dataframe.core import Scalar
 import dask_geopandas
 
-from geopandas.testing import assert_geodataframe_equal
+from geopandas.testing import assert_geodataframe_equal, assert_geoseries_equal
 
 
 @pytest.fixture
@@ -363,6 +363,25 @@ def test_copy_spatial_partitions(geodf_points):
     )
 
 
+def test_set_crs_sets_spatial_partition_crs(geodf_points):
+    dask_obj = dask_geopandas.from_geopandas(geodf_points, npartitions=2)
+
+    dask_obj.calculate_spatial_partitions()
+    dask_obj = dask_obj.set_crs("epsg:4326")
+
+    assert dask_obj.crs == dask_obj.spatial_partitions.crs
+
+
+def test_propagate_on_set_crs(geodf_points):
+    dask_obj = dask_geopandas.from_geopandas(geodf_points, npartitions=2)
+
+    dask_obj.calculate_spatial_partitions()
+    result = dask_obj.set_crs("epsg:4326").spatial_partitions
+    expected = dask_obj.spatial_partitions.set_crs("epsg:4326")
+
+    assert_geoseries_equal(result, expected)
+
+
 @pytest.mark.skipif(
     LooseVersion(geopandas.__version__) <= LooseVersion("0.8.1"),
     reason="geopandas 0.8 has bug in apply",
Repository: geopandas/geopandas

Issue:
TST: tests with invalid values fail with pandas master
We have some recent failures coming from pandas master - 
https://github.com/geopandas/geopandas/runs/4059704198?check_suite_focus=true

All seem to be related to the handling of invalid values but I guess that the fix should happen in pandas? I've got no bandwidth now, so filing it to keep an eye on it.

Comments:

Patch:
diff --git a/geopandas/array.py b/geopandas/array.py
index 0532c08..fd7b7fc 100644
--- a/geopandas/array.py
+++ b/geopandas/array.py
@@ -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


Test patch:
diff --git a/geopandas/tests/test_extension_array.py b/geopandas/tests/test_extension_array.py
index 6e1205b..9582404 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