-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
REF: use fused types in algos_rank_helper #29044
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
Conversation
order = (values, mask) | ||
if rank_t is not uint64_t: | ||
if ascending ^ (na_option == 'top'): | ||
if rank_t is object: |
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 necessarily in scope for this but would be nice if there was a better way to do this via fused types (a dict or inline func?)
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.
Yah I've been giving that some thought. I think we can do that with something like:
cdef inline rank_t get_thing(rank_t val): # <-- totally ignore `val`, just care about rank_t
if rank_t is object: ...
def actual_func(rank_t ...):
cdef:
rank_t val, thing
thing = get_thing(val)
{{endif}} | ||
if tiebreak == TIEBREAK_FIRST: | ||
# need to use a stable sort here | ||
_as = np.lexsort(keys=order) |
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.
Maybe reading wrong but this is duplicated in each conditional branch? Could clean in follow up if so
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.
agreed
for i in range(n): | ||
sum_ranks += i + 1 | ||
dups += 1 | ||
|
||
{{if dtype == 'object'}} | ||
val = util.get_value_at(sorted_data, i) |
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.
Is this line no longer required?
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.
AFAICT it hasnt been needed for a while. I recently removed most usages of util.get_value_at as unnecessary when we know i
is an integer.
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.
looks good. just some small requests, i suppose you have some followups to de-dupliacate
elif rank_t is int64_t: | ||
nan_value = np.iinfo(np.int64).max | ||
|
||
order = (values, mask) |
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.
can you add some comments here
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.
can you be more specific? there is a pretty nice comment up on L69
if rank_t is object: | ||
nan_value = Infinity() | ||
elif rank_t is float64_t: | ||
nan_value = np.inf |
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.
comments here as well
thanks |
No description provided.