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


##########
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:
   Kept this gate intentionally. GeoPandas added the dwithin predicate and 
distance argument to sjoin in version 1.0. The lock resolves GeoPandas 1.0.1 
for Python 3.9 and 1.1.4 for Python 3.10 and newer, so those CI jobs execute 
these tests; only Python 3.8 with GeoPandas 0.13.2 skips because the reference 
API is unavailable. Feature detection would produce the same skip.



##########
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:
   Updated normalization in d19ddd7ee49 to use shapely.to_wkb with hex=True 
while retaining None handling. All four focused parity tests pass.



-- 
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