@@ -457,9 +457,8 @@ def group_rank_{{name}}(ndarray[float64_t, ndim=2] out,
457457 """
458458 cdef:
459459 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
463462 ndarray[int64_t] _as
464463 ndarray[{{c_type}}] masked_vals
465464 ndarray[uint8_t] mask
@@ -539,7 +538,7 @@ def group_rank_{{name}}(ndarray[float64_t, ndim=2] out,
539538 # result once the last duplicate value is encountered
540539 if tiebreak == TIEBREAK_AVERAGE:
541540 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
543542 elif tiebreak == TIEBREAK_MIN:
544543 for j in range(i - dups + 1, i + 1):
545544 out[_as[j], 0] = i - grp_start - dups + 2
@@ -583,6 +582,7 @@ def group_rank_{{name}}(ndarray[float64_t, ndim=2] out,
583582 # so the tiebreaker calculations can decrement that from their position
584583 # if the pct flag is True, go back and overwrite the result for
585584 # 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
586586 if i == N - 1 or labels[_as[i]] != labels[_as[i+1]]:
587587 if pct:
588588 for j in range(grp_start, i + 1):
0 commit comments