@@ -495,7 +495,7 @@ def roll_skew(ndarray[float64_t] values, ndarray[int64_t] start,
495
495
float64_t x = 0 , xx = 0 , xxx = 0
496
496
int64_t nobs = 0 , i, j, N = len (values), nobs_mean = 0
497
497
int64_t s, e
498
- ndarray[float64_t] output, mean_array
498
+ ndarray[float64_t] output, mean_array, values_copy
499
499
bint is_monotonic_increasing_bounds
500
500
501
501
minp = max (minp, 3 )
@@ -504,10 +504,11 @@ def roll_skew(ndarray[float64_t] values, ndarray[int64_t] start,
504
504
)
505
505
output = np.empty(N, dtype = float )
506
506
min_val = np.nanmin(values)
507
+ values_copy = np.copy(values)
507
508
508
509
with nogil:
509
510
for i in range (0 , N):
510
- val = values [i]
511
+ val = values_copy [i]
511
512
if notnan(val):
512
513
nobs_mean += 1
513
514
sum_val += val
@@ -516,7 +517,7 @@ def roll_skew(ndarray[float64_t] values, ndarray[int64_t] start,
516
517
if min_val - mean_val > - 1e5 :
517
518
mean_val = round (mean_val)
518
519
for i in range (0 , N):
519
- values [i] = values [i] - mean_val
520
+ values_copy [i] = values_copy [i] - mean_val
520
521
521
522
for i in range (0 , N):
522
523
@@ -528,7 +529,7 @@ def roll_skew(ndarray[float64_t] values, ndarray[int64_t] start,
528
529
if i == 0 or not is_monotonic_increasing_bounds:
529
530
530
531
for j in range (s, e):
531
- val = values [j]
532
+ val = values_copy [j]
532
533
add_skew(val, & nobs, & x, & xx, & xxx, & compensation_x_add,
533
534
& compensation_xx_add, & compensation_xxx_add)
534
535
@@ -538,13 +539,13 @@ def roll_skew(ndarray[float64_t] values, ndarray[int64_t] start,
538
539
# and removed
539
540
# calculate deletes
540
541
for j in range (start[i - 1 ], s):
541
- val = values [j]
542
+ val = values_copy [j]
542
543
remove_skew(val, & nobs, & x, & xx, & xxx, & compensation_x_remove,
543
544
& compensation_xx_remove, & compensation_xxx_remove)
544
545
545
546
# calculate adds
546
547
for j in range (end[i - 1 ], e):
547
- val = values [j]
548
+ val = values_copy [j]
548
549
add_skew(val, & nobs, & x, & xx, & xxx, & compensation_x_add,
549
550
& compensation_xx_add, & compensation_xxx_add)
550
551
@@ -675,19 +676,20 @@ def roll_kurt(ndarray[float64_t] values, ndarray[int64_t] start,
675
676
float64_t compensation_x_remove = 0 , compensation_x_add = 0
676
677
float64_t x = 0 , xx = 0 , xxx = 0 , xxxx = 0
677
678
int64_t nobs = 0 , i, j, s, e, N = len (values), nobs_mean = 0
678
- ndarray[float64_t] output
679
+ ndarray[float64_t] output, values_copy
679
680
bint is_monotonic_increasing_bounds
680
681
681
682
minp = max (minp, 4 )
682
683
is_monotonic_increasing_bounds = is_monotonic_increasing_start_end_bounds(
683
684
start, end
684
685
)
685
686
output = np.empty(N, dtype = float )
687
+ values_copy = np.copy(values)
686
688
min_val = np.nanmin(values)
687
689
688
690
with nogil:
689
691
for i in range (0 , N):
690
- val = values [i]
692
+ val = values_copy [i]
691
693
if notnan(val):
692
694
nobs_mean += 1
693
695
sum_val += val
@@ -696,7 +698,7 @@ def roll_kurt(ndarray[float64_t] values, ndarray[int64_t] start,
696
698
if min_val - mean_val > - 1e4 :
697
699
mean_val = round (mean_val)
698
700
for i in range (0 , N):
699
- values [i] = values [i] - mean_val
701
+ values_copy [i] = values_copy [i] - mean_val
700
702
701
703
for i in range (0 , N):
702
704
@@ -708,7 +710,7 @@ def roll_kurt(ndarray[float64_t] values, ndarray[int64_t] start,
708
710
if i == 0 or not is_monotonic_increasing_bounds:
709
711
710
712
for j in range (s, e):
711
- add_kurt(values [j], & nobs, & x, & xx, & xxx, & xxxx,
713
+ add_kurt(values_copy [j], & nobs, & x, & xx, & xxx, & xxxx,
712
714
& compensation_x_add, & compensation_xx_add,
713
715
& compensation_xxx_add, & compensation_xxxx_add)
714
716
@@ -718,13 +720,13 @@ def roll_kurt(ndarray[float64_t] values, ndarray[int64_t] start,
718
720
# and removed
719
721
# calculate deletes
720
722
for j in range (start[i - 1 ], s):
721
- remove_kurt(values [j], & nobs, & x, & xx, & xxx, & xxxx,
723
+ remove_kurt(values_copy [j], & nobs, & x, & xx, & xxx, & xxxx,
722
724
& compensation_x_remove, & compensation_xx_remove,
723
725
& compensation_xxx_remove, & compensation_xxxx_remove)
724
726
725
727
# calculate adds
726
728
for j in range (end[i - 1 ], e):
727
- add_kurt(values [j], & nobs, & x, & xx, & xxx, & xxxx,
729
+ add_kurt(values_copy [j], & nobs, & x, & xx, & xxx, & xxxx,
728
730
& compensation_x_add, & compensation_xx_add,
729
731
& compensation_xxx_add, & compensation_xxxx_add)
730
732
0 commit comments