@@ -523,7 +523,7 @@ def roll_skew(ndarray[float64_t] values, ndarray[int64_t] start,
523
523
float64_t x = 0 , xx = 0 , xxx = 0
524
524
int64_t nobs = 0 , i, j, N = len (values), nobs_mean = 0
525
525
int64_t s, e
526
- ndarray[float64_t] output, mean_array
526
+ ndarray[float64_t] output, mean_array, values_copy
527
527
bint is_monotonic_increasing_bounds
528
528
529
529
minp = max (minp, 3 )
@@ -532,10 +532,11 @@ def roll_skew(ndarray[float64_t] values, ndarray[int64_t] start,
532
532
)
533
533
output = np.empty(N, dtype = float )
534
534
min_val = np.nanmin(values)
535
+ values_copy = np.copy(values)
535
536
536
537
with nogil:
537
538
for i in range (0 , N):
538
- val = values [i]
539
+ val = values_copy [i]
539
540
if notnan(val):
540
541
nobs_mean += 1
541
542
sum_val += val
@@ -544,7 +545,7 @@ def roll_skew(ndarray[float64_t] values, ndarray[int64_t] start,
544
545
if min_val - mean_val > - 1e5 :
545
546
mean_val = round (mean_val)
546
547
for i in range (0 , N):
547
- values [i] = values [i] - mean_val
548
+ values_copy [i] = values_copy [i] - mean_val
548
549
549
550
for i in range (0 , N):
550
551
@@ -556,7 +557,7 @@ def roll_skew(ndarray[float64_t] values, ndarray[int64_t] start,
556
557
if i == 0 or not is_monotonic_increasing_bounds:
557
558
558
559
for j in range (s, e):
559
- val = values [j]
560
+ val = values_copy [j]
560
561
add_skew(val, & nobs, & x, & xx, & xxx, & compensation_x_add,
561
562
& compensation_xx_add, & compensation_xxx_add)
562
563
@@ -566,13 +567,13 @@ def roll_skew(ndarray[float64_t] values, ndarray[int64_t] start,
566
567
# and removed
567
568
# calculate deletes
568
569
for j in range (start[i - 1 ], s):
569
- val = values [j]
570
+ val = values_copy [j]
570
571
remove_skew(val, & nobs, & x, & xx, & xxx, & compensation_x_remove,
571
572
& compensation_xx_remove, & compensation_xxx_remove)
572
573
573
574
# calculate adds
574
575
for j in range (end[i - 1 ], e):
575
- val = values [j]
576
+ val = values_copy [j]
576
577
add_skew(val, & nobs, & x, & xx, & xxx, & compensation_x_add,
577
578
& compensation_xx_add, & compensation_xxx_add)
578
579
@@ -703,19 +704,20 @@ def roll_kurt(ndarray[float64_t] values, ndarray[int64_t] start,
703
704
float64_t compensation_x_remove = 0 , compensation_x_add = 0
704
705
float64_t x = 0 , xx = 0 , xxx = 0 , xxxx = 0
705
706
int64_t nobs = 0 , i, j, s, e, N = len (values), nobs_mean = 0
706
- ndarray[float64_t] output
707
+ ndarray[float64_t] output, values_copy
707
708
bint is_monotonic_increasing_bounds
708
709
709
710
minp = max (minp, 4 )
710
711
is_monotonic_increasing_bounds = is_monotonic_increasing_start_end_bounds(
711
712
start, end
712
713
)
713
714
output = np.empty(N, dtype = float )
715
+ values_copy = np.copy(values)
714
716
min_val = np.nanmin(values)
715
717
716
718
with nogil:
717
719
for i in range (0 , N):
718
- val = values [i]
720
+ val = values_copy [i]
719
721
if notnan(val):
720
722
nobs_mean += 1
721
723
sum_val += val
@@ -724,7 +726,7 @@ def roll_kurt(ndarray[float64_t] values, ndarray[int64_t] start,
724
726
if min_val - mean_val > - 1e4 :
725
727
mean_val = round (mean_val)
726
728
for i in range (0 , N):
727
- values [i] = values [i] - mean_val
729
+ values_copy [i] = values_copy [i] - mean_val
728
730
729
731
for i in range (0 , N):
730
732
@@ -736,7 +738,7 @@ def roll_kurt(ndarray[float64_t] values, ndarray[int64_t] start,
736
738
if i == 0 or not is_monotonic_increasing_bounds:
737
739
738
740
for j in range (s, e):
739
- add_kurt(values [j], & nobs, & x, & xx, & xxx, & xxxx,
741
+ add_kurt(values_copy [j], & nobs, & x, & xx, & xxx, & xxxx,
740
742
& compensation_x_add, & compensation_xx_add,
741
743
& compensation_xxx_add, & compensation_xxxx_add)
742
744
@@ -746,13 +748,13 @@ def roll_kurt(ndarray[float64_t] values, ndarray[int64_t] start,
746
748
# and removed
747
749
# calculate deletes
748
750
for j in range (start[i - 1 ], s):
749
- remove_kurt(values [j], & nobs, & x, & xx, & xxx, & xxxx,
751
+ remove_kurt(values_copy [j], & nobs, & x, & xx, & xxx, & xxxx,
750
752
& compensation_x_remove, & compensation_xx_remove,
751
753
& compensation_xxx_remove, & compensation_xxxx_remove)
752
754
753
755
# calculate adds
754
756
for j in range (end[i - 1 ], e):
755
- add_kurt(values [j], & nobs, & x, & xx, & xxx, & xxxx,
757
+ add_kurt(values_copy [j], & nobs, & x, & xx, & xxx, & xxxx,
756
758
& compensation_x_add, & compensation_xx_add,
757
759
& compensation_xxx_add, & compensation_xxxx_add)
758
760
0 commit comments