jiayuasu commented on code in PR #1052: URL: https://github.com/apache/sedona-db/pull/1052#discussion_r3663270987
########## python/sedonadb-geopandas/tests/test_geopandas_compat.py: ########## @@ -0,0 +1,97 @@ +# 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 pytest + +import sedonadb_geopandas as sgpd +from sedonadb_geopandas import GeoDataFrame, GeoSeries, Series + + [email protected] +def cities(): + return gpd.GeoDataFrame( + {"name": ["A", "B", "C"], "pop": [100, 200, 300]}, + geometry=gpd.GeoSeries.from_wkt(["POINT (0 0)", "POINT (1 1)", "POINT (5 5)"]), + crs="EPSG:4326", + ) + + Review Comment: Fixed — the harness now uses `check_crs=True`; agreed that CRS propagation is exactly one of the things worth asserting rather than waving through. One finding while verifying: `check_crs=True` passes with EPSG:4326 data too, including propagation through `to_crs`. The normalization I had worked around only shows up via SQL (`ST_SetSRID(..., 4326)` comes back as OGC:CRS84), not through the `from_geopandas` path, so the fixture did not actually need to change. To keep that honest either way I added a parametrized test over both a geographic (EPSG:4326) and a projected (EPSG:32633) source, plus a harness-driven `to_crs("EPSG:3857")` case that asserts propagation directly. Happy to move the fixtures off 4326 as well if relying on that seems fragile. ########## python/sedonadb-geopandas/python/sedonadb_geopandas/_series.py: ########## @@ -0,0 +1,109 @@ +# 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. +"""pandas/GeoPandas-style Series backed by a SedonaDB expression.""" + + +def _operand(other): + """Unwrap a Series to its expression; pass scalars through unchanged.""" + return other._expr if isinstance(other, Series) else other Review Comment: Good catch — added. `Literal` is not an `Expr` subclass, so it was only surviving by falling through the final catch-all, which is exactly the kind of accident worth making explicit. `_operand` now accepts `(Expr, Literal)` up front, with a test using `lit()` as an operand, and the docstring notes the `lit()` escape hatch for carrying a CRS. -- 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]
