Copilot commented on code in PR #2770:
URL: https://github.com/apache/sedona/pull/2770#discussion_r2964549104


##########
python/sedona/spark/geopandas/geoseries.py:
##########
@@ -1152,7 +1156,7 @@ def line_merge(self, directed=False):
         )
 
     def build_area(self, node=True):
-        if len(self) == 0:
+        if self._is_empty():
             return GeoSeries([], name="polygons", crs=self.crs)

Review Comment:
   In this empty-input early return, `crs=self.crs` will call `GeoSeries.crs`, 
which triggers `_is_empty()` (and thus a Spark action) again. Since this branch 
is only reached when `_is_empty()` is already true, consider returning with 
`crs=None` (or otherwise avoiding `self.crs` here) to prevent an extra Spark 
job on empty inputs.
   ```suggestion
               return GeoSeries([], name="polygons", crs=None)
   ```



##########
python/sedona/spark/geopandas/geoseries.py:
##########
@@ -1189,7 +1193,7 @@ def polygonize(self, node=True, full=False):
                 "Sedona does not support full=True for polygonize."
             )
 
-        if len(self) == 0:
+        if self._is_empty():
             return GeoSeries([], name="polygons", crs=self.crs)
 

Review Comment:
   In this empty-input early return, `crs=self.crs` triggers `_is_empty()` 
again via the `crs` property, causing an extra Spark action even though 
emptiness is already known. Consider returning with `crs=None` (or otherwise 
avoid `self.crs` in this branch) to eliminate the redundant job.



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