Copilot commented on code in PR #2026:
URL: https://github.com/apache/sedona/pull/2026#discussion_r2181048486
##########
python/sedona/geopandas/geoseries.py:
##########
@@ -332,18 +334,88 @@ def length(self):
raise NotImplementedError("This method is not implemented yet.")
@property
- def is_valid(self):
- # Implementation of the abstract method
- raise NotImplementedError("This method is not implemented yet.")
+ def is_valid(self) -> pspd.Series:
Review Comment:
Add an `@property` decorator above `def is_valid` so that `is_valid` remains
a property and users don’t need to call it as a method.
##########
python/sedona/geopandas/geoseries.py:
##########
@@ -358,9 +430,36 @@ def count_interior_rings(self):
raise NotImplementedError("This method is not implemented yet.")
@property
- def is_simple(self):
- # Implementation of the abstract method
- raise NotImplementedError("This method is not implemented yet.")
+ def is_simple(self) -> pspd.Series:
Review Comment:
Add an `@property` decorator above `def is_simple` so that `is_simple`
remains a property and users don’t need to call it as a method.
##########
python/sedona/geopandas/geoseries.py:
##########
@@ -332,18 +334,88 @@ def length(self):
raise NotImplementedError("This method is not implemented yet.")
@property
- def is_valid(self):
- # Implementation of the abstract method
- raise NotImplementedError("This method is not implemented yet.")
+ def is_valid(self) -> pspd.Series:
+ """Returns a ``Series`` of ``dtype('bool')`` with value ``True`` for
+ geometries that are valid.
+
+ Examples
+ --------
+
+ An example with one invalid polygon (a bowtie geometry crossing itself)
+ and one missing geometry:
+
+ >>> from shapely.geometry import Polygon
+ >>> s = geopandas.GeoSeries(
+ ... [
+ ... Polygon([(0, 0), (1, 1), (0, 1)]),
+ ... Polygon([(0,0), (1, 1), (1, 0), (0, 1)]), # bowtie
geometry
+ ... Polygon([(0, 0), (2, 2), (2, 0)]),
+ ... None
+ ... ]
+ ... )
+ >>> s
+ 0 POLYGON ((0 0, 1 1, 0 1, 0 0))
+ 1 POLYGON ((0 0, 1 1, 1 0, 0 1, 0 0))
+ 2 POLYGON ((0 0, 2 2, 2 0, 0 0))
+ 3 None
+ dtype: geometry
+
+ >>> s.is_valid
+ 0 True
+ 1 False
+ 2 True
+ 3 False
+ dtype: bool
+
+ See also
+ --------
+ GeoSeries.is_valid_reason : reason for invalidity
+ """
+ return (
+ self._process_geometry_column("ST_IsValid", rename="is_valid")
+ .to_spark_pandas()
+ .astype("bool")
+ )
def is_valid_reason(self):
# Implementation of the abstract method
raise NotImplementedError("This method is not implemented yet.")
@property
Review Comment:
Add an `@property` decorator above `def is_empty` so that `is_empty` remains
a property and users don’t need to call it as a method.
```suggestion
@property
@property
```
--
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]