@@ -59,11 +59,11 @@ cdef:
59
59
int TIEBREAK_DENSE = 5
60
60
61
61
tiebreakers = {
62
- ' average' : TIEBREAK_AVERAGE,
63
- ' min' : TIEBREAK_MIN,
64
- ' max' : TIEBREAK_MAX,
65
- ' first' : TIEBREAK_FIRST,
66
- ' dense' : TIEBREAK_DENSE,
62
+ ' average' : TIEBREAK_AVERAGE,
63
+ ' min' : TIEBREAK_MIN,
64
+ ' max' : TIEBREAK_MAX,
65
+ ' first' : TIEBREAK_FIRST,
66
+ ' dense' : TIEBREAK_DENSE,
67
67
}
68
68
69
69
@@ -489,7 +489,6 @@ def rank_1d_generic(object in_arr, bint retry=1, ties_method='average',
489
489
bint keep_na = 0
490
490
float count = 0.0
491
491
492
-
493
492
tiebreak = tiebreakers[ties_method]
494
493
495
494
keep_na = na_option == ' keep'
@@ -578,6 +577,7 @@ class Infinity(object):
578
577
__gt__ = lambda self , other : self is not other
579
578
__ge__ = lambda self , other : True
580
579
580
+
581
581
class NegInfinity (object ):
582
582
""" provide a negative Infinity comparision method for ranking """
583
583
@@ -705,7 +705,6 @@ def rank_2d_generic(object in_arr, axis=0, ties_method='average',
705
705
# return result
706
706
707
707
708
-
709
708
cdef inline Py_ssize_t swap(numeric * a, numeric * b) nogil except - 1 :
710
709
cdef numeric t
711
710
@@ -747,11 +746,11 @@ cpdef numeric kth_smallest(numeric[:] a, Py_ssize_t k):
747
746
748
747
cdef inline kth_smallest_c(float64_t* a, Py_ssize_t k, Py_ssize_t n):
749
748
cdef:
750
- Py_ssize_t i,j,l, m
749
+ Py_ssize_t i, j, l, m
751
750
double_t x, t
752
751
753
752
l = 0
754
- m = n- 1
753
+ m = n - 1
755
754
while (l< m):
756
755
x = a[k]
757
756
i = l
@@ -793,13 +792,13 @@ cpdef numeric median(numeric[:] arr):
793
792
794
793
def max_subseq (ndarray[double_t] arr ):
795
794
cdef:
796
- Py_ssize_t i= 0 ,s= 0 ,e= 0 ,T, n
795
+ Py_ssize_t i= 0 , s= 0 , e= 0 , T, n
797
796
double m, S
798
797
799
798
n = len (arr)
800
799
801
800
if len (arr) == 0 :
802
- return (- 1 ,- 1 ,None )
801
+ return (- 1 , - 1 , None )
803
802
804
803
m = arr[0 ]
805
804
S = m
@@ -819,6 +818,7 @@ def max_subseq(ndarray[double_t] arr):
819
818
820
819
return (s, e, m)
821
820
821
+
822
822
def min_subseq (ndarray[double_t] arr ):
823
823
cdef:
824
824
Py_ssize_t s, e
@@ -831,6 +831,7 @@ def min_subseq(ndarray[double_t] arr):
831
831
# ----------------------------------------------------------------------
832
832
# Pairwise correlation/covariance
833
833
834
+
834
835
@ cython.boundscheck (False )
835
836
@ cython.wraparound (False )
836
837
def nancorr (ndarray[float64_t , ndim = 2 ] mat, cov = False , minp = None ):
@@ -890,6 +891,7 @@ def nancorr(ndarray[float64_t, ndim=2] mat, cov=False, minp=None):
890
891
# ----------------------------------------------------------------------
891
892
# Pairwise Spearman correlation
892
893
894
+
893
895
@ cython.boundscheck (False )
894
896
@ cython.wraparound (False )
895
897
def nancorr_spearman (ndarray[float64_t , ndim = 2 ] mat, Py_ssize_t minp = 1 ):
@@ -953,6 +955,7 @@ def nancorr_spearman(ndarray[float64_t, ndim=2] mat, Py_ssize_t minp=1):
953
955
# ----------------------------------------------------------------------
954
956
# group operations
955
957
958
+
956
959
@ cython.wraparound (False )
957
960
@ cython.boundscheck (False )
958
961
def is_lexsorted (list list_of_arrays ):
@@ -967,16 +970,14 @@ def is_lexsorted(list list_of_arrays):
967
970
968
971
cdef int64_t ** vecs = < int64_t** > malloc(nlevels * sizeof(int64_t* ))
969
972
for i from 0 <= i < nlevels:
970
- # vecs[i] = <int64_t *> (<ndarray> list_of_arrays[i]).data
971
-
972
973
arr = list_of_arrays[i]
973
- vecs[i] = < int64_t * > arr.data
974
- # assume uniqueness??
974
+ vecs[i] = < int64_t* > arr.data
975
975
976
+ # Assume uniqueness??
976
977
for i from 1 <= i < n:
977
978
for k from 0 <= k < nlevels:
978
979
cur = vecs[k][i]
979
- pre = vecs[k][i- 1 ]
980
+ pre = vecs[k][i - 1 ]
980
981
if cur == pre:
981
982
continue
982
983
elif cur > pre:
@@ -988,7 +989,8 @@ def is_lexsorted(list list_of_arrays):
988
989
989
990
990
991
@ cython.boundscheck (False )
991
- def groupby_indices (dict ids , ndarray[int64_t] labels , ndarray[int64_t] counts ):
992
+ def groupby_indices (dict ids , ndarray[int64_t] labels ,
993
+ ndarray[int64_t] counts ):
992
994
"""
993
995
turn group_labels output into a combined indexer maping the labels to
994
996
indexers
@@ -1020,7 +1022,7 @@ def groupby_indices(dict ids, ndarray[int64_t] labels, ndarray[int64_t] counts):
1020
1022
for i from 0 <= i < len (counts):
1021
1023
arr = np.empty(counts[i], dtype = np.int64)
1022
1024
result[ids[i]] = arr
1023
- vecs[i] = < int64_t * > arr.data
1025
+ vecs[i] = < int64_t* > arr.data
1024
1026
1025
1027
for i from 0 <= i < n:
1026
1028
k = labels[i]
@@ -1036,6 +1038,7 @@ def groupby_indices(dict ids, ndarray[int64_t] labels, ndarray[int64_t] counts):
1036
1038
free(vecs)
1037
1039
return result
1038
1040
1041
+
1039
1042
@ cython.wraparound (False )
1040
1043
@ cython.boundscheck (False )
1041
1044
def group_labels (ndarray[object] values ):
@@ -1116,6 +1119,7 @@ def groupsort_indexer(ndarray[int64_t] index, Py_ssize_t ngroups):
1116
1119
# ----------------------------------------------------------------------
1117
1120
# first, nth, last
1118
1121
1122
+
1119
1123
@ cython.boundscheck (False )
1120
1124
@ cython.wraparound (False )
1121
1125
def group_nth_object (ndarray[object , ndim = 2 ] out,
@@ -1160,6 +1164,7 @@ def group_nth_object(ndarray[object, ndim=2] out,
1160
1164
else :
1161
1165
out[i, j] = resx[i, j]
1162
1166
1167
+
1163
1168
@ cython.boundscheck (False )
1164
1169
@ cython.wraparound (False )
1165
1170
def group_nth_bin_object (ndarray[object , ndim = 2 ] out,
@@ -1210,6 +1215,7 @@ def group_nth_bin_object(ndarray[object, ndim=2] out,
1210
1215
else :
1211
1216
out[i, j] = resx[i, j]
1212
1217
1218
+
1213
1219
@ cython.boundscheck (False )
1214
1220
@ cython.wraparound (False )
1215
1221
def group_last_object (ndarray[object , ndim = 2 ] out,
@@ -1252,6 +1258,7 @@ def group_last_object(ndarray[object, ndim=2] out,
1252
1258
else :
1253
1259
out[i, j] = resx[i, j]
1254
1260
1261
+
1255
1262
@ cython.boundscheck (False )
1256
1263
@ cython.wraparound (False )
1257
1264
def group_last_bin_object (ndarray[object , ndim = 2 ] out,
@@ -1326,7 +1333,6 @@ cdef inline float64_t _median_linear(float64_t* a, int n):
1326
1333
a = tmp
1327
1334
n -= na_count
1328
1335
1329
-
1330
1336
if n % 2 :
1331
1337
result = kth_smallest_c( a, n / 2 , n)
1332
1338
else :
0 commit comments