@@ -31,7 +31,10 @@ from numpy.math cimport NAN
31
31
cnp.import_array()
32
32
33
33
from pandas._libs cimport util
34
- from pandas._libs.algos cimport kth_smallest_c
34
+ from pandas._libs.algos cimport (
35
+ get_rank_nan_fill_val,
36
+ kth_smallest_c,
37
+ )
35
38
36
39
from pandas._libs.algos import (
37
40
ensure_platform_int,
@@ -989,36 +992,16 @@ cdef inline bint _treat_as_na(numeric_object_t val, bint is_datetimelike) nogil:
989
992
return False
990
993
991
994
992
- cdef numeric_t _get_min_or_max(numeric_t val, bint compute_max, bint is_datetimelike):
995
+ cdef numeric_object_t _get_min_or_max(numeric_object_t val, bint compute_max, bint is_datetimelike):
993
996
"""
994
- Find either the min or the max supported by numeric_t ; 'val' is a placeholder
995
- to effectively make numeric_t an argument.
997
+ Find either the min or the max supported by numeric_object_t ; 'val' is a
998
+ placeholder to effectively make numeric_object_t an argument.
996
999
"""
997
- if numeric_t is int64_t:
998
- if compute_max and is_datetimelike:
999
- return - _int64_max
1000
- # Note(jbrockmendel) 2022-03-15 for reasons unknown, using util.INT64_MIN
1001
- # instead of NPY_NAT here causes build warnings and failure in
1002
- # test_cummax_i8_at_implementation_bound
1003
- return NPY_NAT if compute_max else util.INT64_MAX
1004
- elif numeric_t is int32_t:
1005
- return util.INT32_MIN if compute_max else util.INT32_MAX
1006
- elif numeric_t is int16_t:
1007
- return util.INT16_MIN if compute_max else util.INT16_MAX
1008
- elif numeric_t is int8_t:
1009
- return util.INT8_MIN if compute_max else util.INT8_MAX
1010
-
1011
- elif numeric_t is uint64_t:
1012
- return 0 if compute_max else util.UINT64_MAX
1013
- elif numeric_t is uint32_t:
1014
- return 0 if compute_max else util.UINT32_MAX
1015
- elif numeric_t is uint16_t:
1016
- return 0 if compute_max else util.UINT16_MAX
1017
- elif numeric_t is uint8_t:
1018
- return 0 if compute_max else util.UINT8_MAX
1019
-
1020
- else :
1021
- return - np.inf if compute_max else np.inf
1000
+ return get_rank_nan_fill_val(
1001
+ not compute_max,
1002
+ val = val,
1003
+ is_datetimelike = is_datetimelike,
1004
+ )
1022
1005
1023
1006
1024
1007
cdef numeric_t _get_na_val(numeric_t val, bint is_datetimelike):
0 commit comments