Skip to content

CLN: declare types in rank_1d_, rank_2d #28978

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 1 commit into from
Oct 15, 2019
Merged
Changes from all commits
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
10 changes: 4 additions & 6 deletions pandas/_libs/algos_rank_helper.pxi.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dtypes = [('object', 'object', 'Infinity()', 'NegInfinity()'),

@cython.wraparound(False)
@cython.boundscheck(False)
def rank_1d_{{dtype}}(object in_arr, ties_method='average',
def rank_1d_{{dtype}}({{ctype}}[:] in_arr, ties_method='average',
ascending=True, na_option='keep', pct=False):
"""
Fast NaN-friendly version of scipy.stats.rankdata
Expand Down Expand Up @@ -189,7 +189,7 @@ def rank_1d_{{dtype}}(object in_arr, ties_method='average',
return ranks


def rank_2d_{{dtype}}(object in_arr, axis=0, ties_method='average',
def rank_2d_{{dtype}}({{ctype}}[:, :] in_arr, axis=0, ties_method='average',
ascending=True, na_option='keep', pct=False):
"""
Fast NaN-friendly version of scipy.stats.rankdata
Expand Down Expand Up @@ -226,12 +226,10 @@ def rank_2d_{{dtype}}(object in_arr, axis=0, ties_method='average',

keep_na = na_option == 'keep'

in_arr = np.asarray(in_arr)

if axis == 0:
values = in_arr.T.copy()
values = np.asarray(in_arr).T.copy()
else:
values = in_arr.copy()
values = np.asarray(in_arr).copy()
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because without it cython raises at compile-time because it in_arr and values have different types


{{if dtype == 'object'}}
if values.dtype != np.object_:
Expand Down