-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: allow label memviews to be None #42260
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
CLN: allow label memviews to be None #42260
Conversation
pandas/_libs/algos.pyx
Outdated
rankedy = rank_1d(np.array(maskedy)[:nobs], | ||
labels=labels_nobs) | ||
rankedx = rank_1d(np.array(maskedx)[:nobs]) | ||
rankedy = rank_1d(np.array(maskedy)[:nobs]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if it makes a difference, but np.array -> np.asarray?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, was an oversight no reason to copy here
const intp_t[:] sort_indexer, | ||
# Can make const with cython3 (https://github.com/cython/cython/issues/3222) | ||
rank_t[:] masked_vals, | ||
const uint8_t[:] mask, | ||
TiebreakEnumType tiebreak, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as long as you're shifting these around, can you make everything from here-ish on keyword-only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think cdef functions support keyword-only enforced by "*" (unless you have a workaround, I just tried and saw a cython compile error :)
Changed callers to treat it as keyword-only from after mask, though, which should help
Small comments, generally looks very nice |
thanks @mzeitlin11 |
Saves some unnecessary memory allocations, plus moving towards making
rank_sorted_1d
easier to call. Also have done something similar for allowingmask
to be None, but split that off this pr to keep it simpler.