@@ -457,9 +457,8 @@ def group_rank_{{name}}(ndarray[float64_t, ndim=2] out,
457
457
"""
458
458
cdef:
459
459
TiebreakEnumType tiebreak
460
- Py_ssize_t i, j, N, K
461
- int64_t val_start=0, grp_start=0, dups=0, sum_ranks=0, grp_vals_seen=1
462
- int64_t grp_na_count=0
460
+ Py_ssize_t i, j, N, K, val_start=0, grp_start=0, dups=0, sum_ranks=0
461
+ Py_ssize_t grp_vals_seen=1, grp_na_count=0
463
462
ndarray[int64_t] _as
464
463
ndarray[{{c_type}}] masked_vals
465
464
ndarray[uint8_t] mask
@@ -539,7 +538,7 @@ def group_rank_{{name}}(ndarray[float64_t, ndim=2] out,
539
538
# result once the last duplicate value is encountered
540
539
if tiebreak == TIEBREAK_AVERAGE:
541
540
for j in range(i - dups + 1, i + 1):
542
- out[_as[j], 0] = sum_ranks / dups
541
+ out[_as[j], 0] = sum_ranks / <float64_t> dups
543
542
elif tiebreak == TIEBREAK_MIN:
544
543
for j in range(i - dups + 1, i + 1):
545
544
out[_as[j], 0] = i - grp_start - dups + 2
@@ -583,6 +582,7 @@ def group_rank_{{name}}(ndarray[float64_t, ndim=2] out,
583
582
# so the tiebreaker calculations can decrement that from their position
584
583
# if the pct flag is True, go back and overwrite the result for
585
584
# the group to be divided by the size of the group (excluding na values)
585
+ # also be sure to reset any of the items helping to calculate dups
586
586
if i == N - 1 or labels[_as[i]] != labels[_as[i+1]]:
587
587
if pct:
588
588
for j in range(grp_start, i + 1):
0 commit comments