-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: rank_2d raising with mixed dtypes #38932
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
Changes from 2 commits
3858ca3
5c495f5
aebcde0
4c1690c
743572b
0b3d5e5
6edd2b3
66504de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1112,7 +1112,6 @@ def rank_2d( | |
int tiebreak = 0 | ||
int64_t idx | ||
bint check_mask, condition, keep_na | ||
const int64_t[:] labels | ||
|
||
tiebreak = tiebreakers[ties_method] | ||
|
||
|
@@ -1158,34 +1157,14 @@ def rank_2d( | |
|
||
n, k = (<object>values).shape | ||
ranks = np.empty((n, k), dtype='f8') | ||
# For compatibility when calling rank_1d | ||
labels = np.zeros(k, dtype=np.int64) | ||
|
||
if rank_t is object: | ||
try: | ||
_as = values.argsort(1) | ||
except TypeError: | ||
values = in_arr | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the source of the bug - if |
||
for i in range(len(values)): | ||
ranks[i] = rank_1d( | ||
in_arr[i], | ||
labels=labels, | ||
ties_method=ties_method, | ||
ascending=ascending, | ||
pct=pct | ||
) | ||
if axis == 0: | ||
return ranks.T | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This whole try/except is not necessary because the except clause will always raise a |
||
else: | ||
return ranks | ||
if tiebreak == TIEBREAK_FIRST: | ||
# need to use a stable sort here | ||
_as = values.argsort(axis=1, kind='mergesort') | ||
jreback marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if not ascending: | ||
tiebreak = TIEBREAK_FIRST_DESCENDING | ||
else: | ||
if tiebreak == TIEBREAK_FIRST: | ||
# need to use a stable sort here | ||
_as = values.argsort(axis=1, kind='mergesort') | ||
if not ascending: | ||
tiebreak = TIEBREAK_FIRST_DESCENDING | ||
else: | ||
_as = values.argsort(1) | ||
_as = values.argsort(1) | ||
|
||
if not ascending: | ||
_as = _as[:, ::-1] | ||
|
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.
if there is not issue (its fine don't create one), but add this PR number as the issue number.
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.
Thanks for committing that, yep no issue