Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CNL: Remove unnecessary filtering of counts from get_num_geometries #248

Merged
merged 2 commits into from
Nov 20, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 3 additions & 6 deletions pygeos/_geometry.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,10 @@ def get_parts(object[:] array):
cdef 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
if count == 0:
# return immediately if there are no geometries to return
# count is negative when the only entries in array are None
brendan-ward marked this conversation as resolved.
Show resolved Hide resolved
return (
np.empty(shape=(0, ), dtype=np.object),
Expand Down