Skip to content

BLD: Suppressing errors while compling pandas/_libs/groupby #32794

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

Merged
merged 5 commits into from
Mar 19, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions pandas/_libs/groupby.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,9 @@ def group_last(rank_t[:, :] out,

assert min_count == -1, "'min_count' only used in add and prod"

if not len(values) == len(labels):
# NOTE:
# Casting to avoid build warnings
if not len(values) == <Py_ssize_t>len(labels):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to get the same result without casting? Maybe labels.shape[0] for memory views?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WillAyd It works!


Just so I know for future times, are we trying to avoid casting?

or casting is not possible with memory views?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's an easily available approach that doesn't require casting then should almost always go that route

raise AssertionError("len(index) != len(labels)")

nobs = np.zeros((<object>out).shape, dtype=np.int64)
Expand Down Expand Up @@ -960,7 +962,9 @@ def group_nth(rank_t[:, :] out,

assert min_count == -1, "'min_count' only used in add and prod"

if not len(values) == len(labels):
# NOTE:
# Casting to avoid build warnings
if not len(values) == <Py_ssize_t>len(labels):
raise AssertionError("len(index) != len(labels)")

nobs = np.zeros((<object>out).shape, dtype=np.int64)
Expand Down Expand Up @@ -1254,7 +1258,9 @@ def group_max(groupby_t[:, :] out,

assert min_count == -1, "'min_count' only used in add and prod"

if not len(values) == len(labels):
# NOTE:
# Casting to avoid build warnings
if not len(values) == <Py_ssize_t>len(labels):
raise AssertionError("len(index) != len(labels)")

nobs = np.zeros((<object>out).shape, dtype=np.int64)
Expand Down Expand Up @@ -1327,7 +1333,9 @@ def group_min(groupby_t[:, :] out,

assert min_count == -1, "'min_count' only used in add and prod"

if not len(values) == len(labels):
# NOTE:
# Casting to avoid build warnings
if not len(values) == <Py_ssize_t>len(labels):
raise AssertionError("len(index) != len(labels)")

nobs = np.zeros((<object>out).shape, dtype=np.int64)
Expand Down