This is an automated email from the ASF dual-hosted git repository.
jiayu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sedona.git
The following commit(s) were added to refs/heads/master by this push:
new 76efab911f [GH-2377] test `is_closed` on all geo types (#2387)
76efab911f is described below
commit 76efab911fd9982dfb44ef625dc5b0b9facaa83d
Author: Yunchi Pang <[email protected]>
AuthorDate: Sat Oct 11 18:16:01 2025 -0700
[GH-2377] test `is_closed` on all geo types (#2387)
---
python/sedona/spark/geopandas/geoseries.py | 7 ++++++-
python/tests/geopandas/test_match_geopandas_series.py | 4 ++--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/python/sedona/spark/geopandas/geoseries.py
b/python/sedona/spark/geopandas/geoseries.py
index 55af19673f..361b46b197 100644
--- a/python/sedona/spark/geopandas/geoseries.py
+++ b/python/sedona/spark/geopandas/geoseries.py
@@ -976,7 +976,12 @@ class GeoSeries(GeoFrame, pspd.Series):
@property
def is_closed(self):
- spark_expr = stf.ST_IsClosed(self.spark.column)
+ # Only check LineStrings; return False for all other geometry types
+ spark_expr = F.when(
+ stf.ST_GeometryType(self.spark.column) == "ST_LineString",
+ stf.ST_IsClosed(self.spark.column),
+ ).otherwise(False)
+
result = self._query_geometry_column(
spark_expr,
returns_geom=False,
diff --git a/python/tests/geopandas/test_match_geopandas_series.py
b/python/tests/geopandas/test_match_geopandas_series.py
index 250c133eef..ebbc699ca3 100644
--- a/python/tests/geopandas/test_match_geopandas_series.py
+++ b/python/tests/geopandas/test_match_geopandas_series.py
@@ -590,8 +590,8 @@ class TestMatchGeopandasSeries(TestGeopandasBase):
def test_is_closed(self):
if parse_version(gpd.__version__) < parse_version("1.0.0"):
pytest.skip("geopandas is_closed requires version 1.0.0 or higher")
- # is_closed is only meaningful for linestrings so we use
self.linestrings instead of self.geoms
- for geom in self.linestrings:
+ # Test all geometry types to ensure non-LineString/LinearRing
geometries return False
+ for geom in self.geoms:
sgpd_result = GeoSeries(geom).is_closed
gpd_result = gpd.GeoSeries(geom).is_closed
self.check_pd_series_equal(sgpd_result, gpd_result)