We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ac42e67 commit 38a5ed3Copy full SHA for 38a5ed3
micall/utils/overlap_stitcher.py
@@ -92,15 +92,10 @@ def consecutive_true_counts(arr: np.ndarray) -> np.ndarray:
92
up to (and including) index i, resetting on False.
93
"""
94
95
- n = len(arr)
96
- out = np.empty(n, dtype=np.int64)
97
- count = 0
98
99
- for i in range(n):
100
- count = (count + 1) * arr[i]
101
- out[i] = count
102
-
103
- return out
+ c = np.cumsum(arr) # running count of 1s
+ z = np.where(arr == 0, c, 0) # cumsum value at zeros
+ return (c - np.maximum.accumulate(z)).astype(np.int64)
104
105
106
def exp_accumulate_array_positive(array: np.ndarray) -> np.ndarray:
0 commit comments