Skip to content

CLN: share rank_t fused type #43789

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 3 commits into from
Sep 29, 2021
Merged
Show file tree
Hide file tree
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
8 changes: 1 addition & 7 deletions pandas/_libs/algos.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ from numpy cimport (
cnp.import_array()

cimport pandas._libs.util as util
from pandas._libs.dtypes cimport rank_t
from pandas._libs.khash cimport (
kh_destroy_int64,
kh_get_int64,
Expand Down Expand Up @@ -860,13 +861,6 @@ def is_monotonic(ndarray[algos_t, ndim=1] arr, bint timelike):
# rank_1d, rank_2d
# ----------------------------------------------------------------------

ctypedef fused rank_t:
object
float64_t
uint64_t
int64_t


cdef rank_t get_rank_nan_fill_val(bint rank_nans_highest, rank_t[:] _=None):
"""
Return the value we'll use to represent missing values when sorting depending
Expand Down
17 changes: 17 additions & 0 deletions pandas/_libs/dtypes.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""
Common location for shared fused types
"""

from numpy cimport (
float32_t,
float64_t,
int64_t,
uint64_t,
)

ctypedef fused rank_t:
Copy link
Contributor

Choose a reason for hiding this comment

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

can we give this a descriptive name, maybe numeric_object_t or similiar? (of course can update these later too which is fine)

Copy link
Member Author

Choose a reason for hiding this comment

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

sounds like a good starting point, have updated

float64_t
float32_t
int64_t
uint64_t
object
9 changes: 1 addition & 8 deletions pandas/_libs/groupby.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ from pandas._libs.algos import (
take_2d_axis1_float64_float64,
)

from pandas._libs.dtypes cimport rank_t
from pandas._libs.missing cimport checknull


Expand Down Expand Up @@ -921,14 +922,6 @@ def group_quantile(ndarray[float64_t, ndim=2] out,
# group_nth, group_last, group_rank
# ----------------------------------------------------------------------

ctypedef fused rank_t:
float64_t
float32_t
int64_t
uint64_t
object


cdef inline bint _treat_as_na(rank_t val, bint is_datetimelike) nogil:
if rank_t is object:
# Should never be used, but we need to avoid the `val != val` below
Expand Down