Skip to content

Commit

Permalink
CNL: Remove unnecessary filtering of counts from get_num_geometries (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
brendan-ward committed Nov 20, 2020
1 parent dd952fe commit ce00f15
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions pygeos/_geometry.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,10 @@ def get_parts(object[:] array):
cdef const GEOSGeometry *part = NULL

counts = pygeos.get_num_geometries(array)
cdef Py_ssize_t count = counts.sum()

# None elements in array return -1 for count, so
# they must be filtered out before calculating total count
cdef Py_ssize_t count = counts[counts>0].sum()

if count <= 0:
# return immeidately if there are no geometries to return
# count is negative when the only entries in array are None
if count == 0:
# return immediately if there are no geometries to return
return (
np.empty(shape=(0, ), dtype=np.object),
np.empty(shape=(0, ), dtype=np.intp)
Expand Down

0 comments on commit ce00f15

Please sign in to comment.