Copilot commented on code in PR #2466:
URL: https://github.com/apache/sedona/pull/2466#discussion_r3612232732


##########
python/tests/geopandas/test_sjoin_match.py:
##########
@@ -0,0 +1,122 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import geopandas as gpd
+import pandas as pd
+import pytest
+import shapely
+from packaging.version import parse as parse_version
+from shapely.geometry import Point
+
+from sedona.spark.geopandas import GeoDataFrame, sjoin
+from tests.geopandas.test_geopandas_base import TestGeopandasBase
+
+
[email protected](
+    parse_version(shapely.__version__) < parse_version("2.0.0"),
+    reason=f"Tests require shapely>=2.0.0, but found v{shapely.__version__}",
+)
[email protected](
+    parse_version(gpd.__version__) < parse_version("1.0.0"),
+    reason=f"GeoPandas {gpd.__version__} does not support dwithin spatial 
joins",
+)

Review Comment:
   The GeoPandas version gate is likely too strict: the project allows 
GeoPandas <1.0 (see python/pyproject.toml note about not pinning 
geopandas>=0.14.4 for Python 3.8), so this test module may be skipped in CI and 
not improve coverage. Prefer feature-detection (e.g., whether gpd.sjoin accepts 
a `distance` parameter) instead of requiring GeoPandas>=1.0.0.



##########
python/tests/geopandas/test_sjoin_match.py:
##########
@@ -0,0 +1,122 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import geopandas as gpd
+import pandas as pd
+import pytest
+import shapely
+from packaging.version import parse as parse_version
+from shapely.geometry import Point
+
+from sedona.spark.geopandas import GeoDataFrame, sjoin
+from tests.geopandas.test_geopandas_base import TestGeopandasBase
+
+
[email protected](
+    parse_version(shapely.__version__) < parse_version("2.0.0"),
+    reason=f"Tests require shapely>=2.0.0, but found v{shapely.__version__}",
+)
[email protected](
+    parse_version(gpd.__version__) < parse_version("1.0.0"),
+    reason=f"GeoPandas {gpd.__version__} does not support dwithin spatial 
joins",
+)
+class TestSJoinDWithinMatch(TestGeopandasBase):
+    def setup_method(self):
+        super().setup_method()
+
+        left_data = {
+            "id": ["origin", "middle", "far"],
+            "geometry": [Point(0, 0), Point(3, 0), Point(10, 0)],
+        }
+        right_data = {
+            "id": ["east", "west", "near_middle", "remote"],
+            "geometry": [
+                Point(0.25, 0),
+                Point(-0.4, 0),
+                Point(3.75, 0),
+                Point(20, 0),
+            ],
+        }
+
+        self.sedona_left = GeoDataFrame(left_data)
+        self.sedona_right = GeoDataFrame(right_data)
+        self.geopandas_left = gpd.GeoDataFrame(left_data)
+        self.geopandas_right = gpd.GeoDataFrame(right_data)
+
+    @staticmethod
+    def _normalized_rows(joined):
+        if isinstance(joined, GeoDataFrame):
+            joined = joined.to_geopandas()
+
+        rows = []
+        for row in joined[["id_left", "id_right", 
"geometry"]].itertuples(index=False):
+            right_id = None if pd.isna(row.id_right) else row.id_right
+            geometry = None if row.geometry is None else row.geometry.wkb_hex

Review Comment:
   `row.geometry.wkb_hex` is not used elsewhere in the test suite and is 
brittle across Shapely versions. Since this module already requires 
Shapely>=2.0, use `shapely.to_wkb(..., hex=True)` (or `.wkb.hex()`) for a 
stable hex representation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to