You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@sedona.apache.org by "petern48 (via GitHub)" <gi...@apache.org> on 2025/06/29 05:57:29 UTC

[PR] [GH-2025] Geopandas.GeoSeries: Implement is_valid and is_empty [sedona]

petern48 opened a new pull request, #2026:
URL: https://github.com/apache/sedona/pull/2026

   ## Did you read the Contributor Guide?
   
   - Yes, I have read the [Contributor Rules](https://sedona.apache.org/latest/community/rule/) and [Contributor Development Guide](https://sedona.apache.org/latest/community/develop/)
   
   ## Is this PR related to a ticket?
   - Yes, and the PR name follows the format `[GH-XXX] my subject`. Closes #2025
   
   ## What changes were proposed in this PR?
   Implement is_valid and is_empty
   
   ## How was this patch tested?
   Added tests
   
   ## Did this PR include necessary documentation updates?
   
   - Yes, I have updated the documentation.


-- 
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: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [GH-2025] Geopandas.GeoSeries: Implement is_valid, is_empty, is_simple [sedona]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
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: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [GH-2025] Geopandas.GeoSeries: Implement is_valid, is_empty, is_simple [sedona]

Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu merged PR #2026:
URL: https://github.com/apache/sedona/pull/2026


-- 
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: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org