Skip to content

Commit aa0a659

Browse files
committed
fix wraparound/boundschecks
1 parent 7491509 commit aa0a659

File tree

2 files changed

+44
-41
lines changed

2 files changed

+44
-41
lines changed

pandas/src/generate_code.py

+17-16
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ def groupby_%(name)s(ndarray[%(c_type)s] index, ndarray labels):
691691
"""
692692

693693
group_last_template = """@cython.wraparound(False)
694-
@cython.wraparound(False)
694+
@cython.boundscheck(False)
695695
def group_last_%(name)s(ndarray[%(dest_type2)s, ndim=2] out,
696696
ndarray[int64_t] counts,
697697
ndarray[%(c_type)s, ndim=2] values,
@@ -736,7 +736,7 @@ def group_last_%(name)s(ndarray[%(dest_type2)s, ndim=2] out,
736736
"""
737737

738738
group_last_bin_template = """@cython.wraparound(False)
739-
@cython.wraparound(False)
739+
@cython.boundscheck(False)
740740
def group_last_bin_%(name)s(ndarray[%(dest_type2)s, ndim=2] out,
741741
ndarray[int64_t] counts,
742742
ndarray[%(c_type)s, ndim=2] values,
@@ -781,8 +781,8 @@ def group_last_bin_%(name)s(ndarray[%(dest_type2)s, ndim=2] out,
781781
out[i, j] = resx[i, j]
782782
"""
783783

784-
group_nth_bin_template = """@cython.boundscheck(False)
785-
@cython.wraparound(False)
784+
group_nth_bin_template = """@cython.wraparound(False)
785+
@cython.boundscheck(False)
786786
def group_nth_bin_%(name)s(ndarray[%(dest_type2)s, ndim=2] out,
787787
ndarray[int64_t] counts,
788788
ndarray[%(c_type)s, ndim=2] values,
@@ -828,8 +828,8 @@ def group_nth_bin_%(name)s(ndarray[%(dest_type2)s, ndim=2] out,
828828
out[i, j] = resx[i, j]
829829
"""
830830

831-
group_nth_template = """@cython.boundscheck(False)
832-
@cython.wraparound(False)
831+
group_nth_template = """@cython.wraparound(False)
832+
@cython.boundscheck(False)
833833
def group_nth_%(name)s(ndarray[%(dest_type2)s, ndim=2] out,
834834
ndarray[int64_t] counts,
835835
ndarray[%(c_type)s, ndim=2] values,
@@ -874,8 +874,8 @@ def group_nth_%(name)s(ndarray[%(dest_type2)s, ndim=2] out,
874874
out[i, j] = resx[i, j]
875875
"""
876876

877-
group_add_template = """@cython.boundscheck(False)
878-
@cython.wraparound(False)
877+
group_add_template = """@cython.wraparound(False)
878+
@cython.boundscheck(False)
879879
def group_add_%(name)s(ndarray[%(dest_type2)s, ndim=2] out,
880880
ndarray[int64_t] counts,
881881
ndarray[%(c_type)s, ndim=2] values,
@@ -938,8 +938,8 @@ def group_add_%(name)s(ndarray[%(dest_type2)s, ndim=2] out,
938938
out[i, j] = sumx[i, j]
939939
"""
940940

941-
group_add_bin_template = """@cython.boundscheck(False)
942-
@cython.wraparound(False)
941+
group_add_bin_template = """@cython.wraparound(False)
942+
@cython.boundscheck(False)
943943
def group_add_bin_%(name)s(ndarray[%(dest_type2)s, ndim=2] out,
944944
ndarray[int64_t] counts,
945945
ndarray[%(dest_type2)s, ndim=2] values,
@@ -999,8 +999,8 @@ def group_add_bin_%(name)s(ndarray[%(dest_type2)s, ndim=2] out,
999999
out[i, j] = sumx[i, j]
10001000
"""
10011001

1002-
group_prod_template = """@cython.boundscheck(False)
1003-
@cython.wraparound(False)
1002+
group_prod_template = """@cython.wraparound(False)
1003+
@cython.boundscheck(False)
10041004
def group_prod_%(name)s(ndarray[%(dest_type2)s, ndim=2] out,
10051005
ndarray[int64_t] counts,
10061006
ndarray[%(c_type)s, ndim=2] values,
@@ -1058,8 +1058,8 @@ def group_prod_%(name)s(ndarray[%(dest_type2)s, ndim=2] out,
10581058
out[i, j] = prodx[i, j]
10591059
"""
10601060

1061-
group_prod_bin_template = """@cython.boundscheck(False)
1062-
@cython.wraparound(False)
1061+
group_prod_bin_template = """@cython.wraparound(False)
1062+
@cython.boundscheck(False)
10631063
def group_prod_bin_%(name)s(ndarray[%(dest_type2)s, ndim=2] out,
10641064
ndarray[int64_t] counts,
10651065
ndarray[%(dest_type2)s, ndim=2] values,
@@ -1286,8 +1286,8 @@ def group_count_%(name)s(ndarray[%(dest_type2)s, ndim=2] out,
12861286
12871287
"""
12881288

1289-
group_count_bin_template = """@cython.boundscheck(False)
1290-
@cython.wraparound(False)
1289+
group_count_bin_template = """@cython.wraparound(False)
1290+
@cython.boundscheck(False)
12911291
def group_count_bin_%(name)s(ndarray[%(dest_type2)s, ndim=2] out,
12921292
ndarray[int64_t] counts,
12931293
ndarray[%(c_type)s, ndim=2] values,
@@ -1634,6 +1634,7 @@ def group_mean_%(name)s(ndarray[%(dest_type2)s, ndim=2] out,
16341634
"""
16351635

16361636
group_mean_bin_template = """
1637+
@cython.boundscheck(False)
16371638
def group_mean_bin_%(name)s(ndarray[%(dest_type2)s, ndim=2] out,
16381639
ndarray[int64_t] counts,
16391640
ndarray[%(dest_type2)s, ndim=2] values,

pandas/src/generated.pyx

+27-25
Original file line numberDiff line numberDiff line change
@@ -6596,8 +6596,8 @@ def diff_2d_int64(ndarray[int64_t, ndim=2] arr,
65966596
for j in range(start, stop):
65976597
out[i, j] = arr[i, j] - arr[i, j - periods]
65986598

6599-
@cython.boundscheck(False)
66006599
@cython.wraparound(False)
6600+
@cython.boundscheck(False)
66016601
def group_add_float64(ndarray[float64_t, ndim=2] out,
66026602
ndarray[int64_t] counts,
66036603
ndarray[float64_t, ndim=2] values,
@@ -6658,8 +6658,8 @@ def group_add_float64(ndarray[float64_t, ndim=2] out,
66586658
out[i, j] = NAN
66596659
else:
66606660
out[i, j] = sumx[i, j]
6661-
@cython.boundscheck(False)
66626661
@cython.wraparound(False)
6662+
@cython.boundscheck(False)
66636663
def group_add_float32(ndarray[float32_t, ndim=2] out,
66646664
ndarray[int64_t] counts,
66656665
ndarray[float32_t, ndim=2] values,
@@ -6721,8 +6721,8 @@ def group_add_float32(ndarray[float32_t, ndim=2] out,
67216721
else:
67226722
out[i, j] = sumx[i, j]
67236723

6724-
@cython.boundscheck(False)
67256724
@cython.wraparound(False)
6725+
@cython.boundscheck(False)
67266726
def group_add_bin_float64(ndarray[float64_t, ndim=2] out,
67276727
ndarray[int64_t] counts,
67286728
ndarray[float64_t, ndim=2] values,
@@ -6780,8 +6780,8 @@ def group_add_bin_float64(ndarray[float64_t, ndim=2] out,
67806780
out[i, j] = NAN
67816781
else:
67826782
out[i, j] = sumx[i, j]
6783-
@cython.boundscheck(False)
67846783
@cython.wraparound(False)
6784+
@cython.boundscheck(False)
67856785
def group_add_bin_float32(ndarray[float32_t, ndim=2] out,
67866786
ndarray[int64_t] counts,
67876787
ndarray[float32_t, ndim=2] values,
@@ -6840,8 +6840,8 @@ def group_add_bin_float32(ndarray[float32_t, ndim=2] out,
68406840
else:
68416841
out[i, j] = sumx[i, j]
68426842

6843-
@cython.boundscheck(False)
68446843
@cython.wraparound(False)
6844+
@cython.boundscheck(False)
68456845
def group_prod_float64(ndarray[float64_t, ndim=2] out,
68466846
ndarray[int64_t] counts,
68476847
ndarray[float64_t, ndim=2] values,
@@ -6897,8 +6897,8 @@ def group_prod_float64(ndarray[float64_t, ndim=2] out,
68976897
out[i, j] = NAN
68986898
else:
68996899
out[i, j] = prodx[i, j]
6900-
@cython.boundscheck(False)
69016900
@cython.wraparound(False)
6901+
@cython.boundscheck(False)
69026902
def group_prod_float32(ndarray[float32_t, ndim=2] out,
69036903
ndarray[int64_t] counts,
69046904
ndarray[float32_t, ndim=2] values,
@@ -6955,8 +6955,8 @@ def group_prod_float32(ndarray[float32_t, ndim=2] out,
69556955
else:
69566956
out[i, j] = prodx[i, j]
69576957

6958-
@cython.boundscheck(False)
69596958
@cython.wraparound(False)
6959+
@cython.boundscheck(False)
69606960
def group_prod_bin_float64(ndarray[float64_t, ndim=2] out,
69616961
ndarray[int64_t] counts,
69626962
ndarray[float64_t, ndim=2] values,
@@ -7013,8 +7013,8 @@ def group_prod_bin_float64(ndarray[float64_t, ndim=2] out,
70137013
out[i, j] = NAN
70147014
else:
70157015
out[i, j] = prodx[i, j]
7016-
@cython.boundscheck(False)
70177016
@cython.wraparound(False)
7017+
@cython.boundscheck(False)
70187018
def group_prod_bin_float32(ndarray[float32_t, ndim=2] out,
70197019
ndarray[int64_t] counts,
70207020
ndarray[float32_t, ndim=2] values,
@@ -7432,6 +7432,7 @@ def group_mean_float32(ndarray[float32_t, ndim=2] out,
74327432
out[i, j] = sumx[i, j] / count
74337433

74347434

7435+
@cython.boundscheck(False)
74357436
def group_mean_bin_float64(ndarray[float64_t, ndim=2] out,
74367437
ndarray[int64_t] counts,
74377438
ndarray[float64_t, ndim=2] values,
@@ -7486,6 +7487,7 @@ def group_mean_bin_float64(ndarray[float64_t, ndim=2] out,
74867487
else:
74877488
out[i, j] = sumx[i, j] / count
74887489

7490+
@cython.boundscheck(False)
74897491
def group_mean_bin_float32(ndarray[float32_t, ndim=2] out,
74907492
ndarray[int64_t] counts,
74917493
ndarray[float32_t, ndim=2] values,
@@ -7686,7 +7688,7 @@ def group_ohlc_float32(ndarray[float32_t, ndim=2] out,
76867688
out[b, 3] = vclose
76877689

76887690
@cython.wraparound(False)
7689-
@cython.wraparound(False)
7691+
@cython.boundscheck(False)
76907692
def group_last_float64(ndarray[float64_t, ndim=2] out,
76917693
ndarray[int64_t] counts,
76927694
ndarray[float64_t, ndim=2] values,
@@ -7729,7 +7731,7 @@ def group_last_float64(ndarray[float64_t, ndim=2] out,
77297731
else:
77307732
out[i, j] = resx[i, j]
77317733
@cython.wraparound(False)
7732-
@cython.wraparound(False)
7734+
@cython.boundscheck(False)
77337735
def group_last_float32(ndarray[float32_t, ndim=2] out,
77347736
ndarray[int64_t] counts,
77357737
ndarray[float32_t, ndim=2] values,
@@ -7772,7 +7774,7 @@ def group_last_float32(ndarray[float32_t, ndim=2] out,
77727774
else:
77737775
out[i, j] = resx[i, j]
77747776
@cython.wraparound(False)
7775-
@cython.wraparound(False)
7777+
@cython.boundscheck(False)
77767778
def group_last_int64(ndarray[int64_t, ndim=2] out,
77777779
ndarray[int64_t] counts,
77787780
ndarray[int64_t, ndim=2] values,
@@ -7816,7 +7818,7 @@ def group_last_int64(ndarray[int64_t, ndim=2] out,
78167818
out[i, j] = resx[i, j]
78177819

78187820
@cython.wraparound(False)
7819-
@cython.wraparound(False)
7821+
@cython.boundscheck(False)
78207822
def group_last_bin_float64(ndarray[float64_t, ndim=2] out,
78217823
ndarray[int64_t] counts,
78227824
ndarray[float64_t, ndim=2] values,
@@ -7860,7 +7862,7 @@ def group_last_bin_float64(ndarray[float64_t, ndim=2] out,
78607862
else:
78617863
out[i, j] = resx[i, j]
78627864
@cython.wraparound(False)
7863-
@cython.wraparound(False)
7865+
@cython.boundscheck(False)
78647866
def group_last_bin_float32(ndarray[float32_t, ndim=2] out,
78657867
ndarray[int64_t] counts,
78667868
ndarray[float32_t, ndim=2] values,
@@ -7904,7 +7906,7 @@ def group_last_bin_float32(ndarray[float32_t, ndim=2] out,
79047906
else:
79057907
out[i, j] = resx[i, j]
79067908
@cython.wraparound(False)
7907-
@cython.wraparound(False)
7909+
@cython.boundscheck(False)
79087910
def group_last_bin_int64(ndarray[int64_t, ndim=2] out,
79097911
ndarray[int64_t] counts,
79107912
ndarray[int64_t, ndim=2] values,
@@ -7948,8 +7950,8 @@ def group_last_bin_int64(ndarray[int64_t, ndim=2] out,
79487950
else:
79497951
out[i, j] = resx[i, j]
79507952

7951-
@cython.boundscheck(False)
79527953
@cython.wraparound(False)
7954+
@cython.boundscheck(False)
79537955
def group_nth_float64(ndarray[float64_t, ndim=2] out,
79547956
ndarray[int64_t] counts,
79557957
ndarray[float64_t, ndim=2] values,
@@ -7992,8 +7994,8 @@ def group_nth_float64(ndarray[float64_t, ndim=2] out,
79927994
out[i, j] = NAN
79937995
else:
79947996
out[i, j] = resx[i, j]
7995-
@cython.boundscheck(False)
79967997
@cython.wraparound(False)
7998+
@cython.boundscheck(False)
79977999
def group_nth_float32(ndarray[float32_t, ndim=2] out,
79988000
ndarray[int64_t] counts,
79998001
ndarray[float32_t, ndim=2] values,
@@ -8036,8 +8038,8 @@ def group_nth_float32(ndarray[float32_t, ndim=2] out,
80368038
out[i, j] = NAN
80378039
else:
80388040
out[i, j] = resx[i, j]
8039-
@cython.boundscheck(False)
80408041
@cython.wraparound(False)
8042+
@cython.boundscheck(False)
80418043
def group_nth_int64(ndarray[int64_t, ndim=2] out,
80428044
ndarray[int64_t] counts,
80438045
ndarray[int64_t, ndim=2] values,
@@ -8081,8 +8083,8 @@ def group_nth_int64(ndarray[int64_t, ndim=2] out,
80818083
else:
80828084
out[i, j] = resx[i, j]
80838085

8084-
@cython.boundscheck(False)
80858086
@cython.wraparound(False)
8087+
@cython.boundscheck(False)
80868088
def group_nth_bin_float64(ndarray[float64_t, ndim=2] out,
80878089
ndarray[int64_t] counts,
80888090
ndarray[float64_t, ndim=2] values,
@@ -8126,8 +8128,8 @@ def group_nth_bin_float64(ndarray[float64_t, ndim=2] out,
81268128
out[i, j] = NAN
81278129
else:
81288130
out[i, j] = resx[i, j]
8129-
@cython.boundscheck(False)
81308131
@cython.wraparound(False)
8132+
@cython.boundscheck(False)
81318133
def group_nth_bin_float32(ndarray[float32_t, ndim=2] out,
81328134
ndarray[int64_t] counts,
81338135
ndarray[float32_t, ndim=2] values,
@@ -8171,8 +8173,8 @@ def group_nth_bin_float32(ndarray[float32_t, ndim=2] out,
81718173
out[i, j] = NAN
81728174
else:
81738175
out[i, j] = resx[i, j]
8174-
@cython.boundscheck(False)
81758176
@cython.wraparound(False)
8177+
@cython.boundscheck(False)
81768178
def group_nth_bin_int64(ndarray[int64_t, ndim=2] out,
81778179
ndarray[int64_t] counts,
81788180
ndarray[int64_t, ndim=2] values,
@@ -9130,8 +9132,8 @@ def group_count_int64(ndarray[int64_t, ndim=2] out,
91309132

91319133

91329134

9133-
@cython.boundscheck(False)
91349135
@cython.wraparound(False)
9136+
@cython.boundscheck(False)
91359137
def group_count_bin_float64(ndarray[float64_t, ndim=2] out,
91369138
ndarray[int64_t] counts,
91379139
ndarray[float64_t, ndim=2] values,
@@ -9164,8 +9166,8 @@ def group_count_bin_float64(ndarray[float64_t, ndim=2] out,
91649166
out[i, j] = nobs[i, j]
91659167

91669168

9167-
@cython.boundscheck(False)
91689169
@cython.wraparound(False)
9170+
@cython.boundscheck(False)
91699171
def group_count_bin_float32(ndarray[float32_t, ndim=2] out,
91709172
ndarray[int64_t] counts,
91719173
ndarray[float32_t, ndim=2] values,
@@ -9198,8 +9200,8 @@ def group_count_bin_float32(ndarray[float32_t, ndim=2] out,
91989200
out[i, j] = nobs[i, j]
91999201

92009202

9201-
@cython.boundscheck(False)
92029203
@cython.wraparound(False)
9204+
@cython.boundscheck(False)
92039205
def group_count_bin_int64(ndarray[int64_t, ndim=2] out,
92049206
ndarray[int64_t] counts,
92059207
ndarray[int64_t, ndim=2] values,
@@ -9232,8 +9234,8 @@ def group_count_bin_int64(ndarray[int64_t, ndim=2] out,
92329234
out[i, j] = nobs[i, j]
92339235

92349236

9235-
@cython.boundscheck(False)
92369237
@cython.wraparound(False)
9238+
@cython.boundscheck(False)
92379239
def group_count_bin_object(ndarray[object, ndim=2] out,
92389240
ndarray[int64_t] counts,
92399241
ndarray[object, ndim=2] values,
@@ -9266,8 +9268,8 @@ def group_count_bin_object(ndarray[object, ndim=2] out,
92669268
out[i, j] = nobs[i, j]
92679269

92689270

9269-
@cython.boundscheck(False)
92709271
@cython.wraparound(False)
9272+
@cython.boundscheck(False)
92719273
def group_count_bin_int64(ndarray[int64_t, ndim=2] out,
92729274
ndarray[int64_t] counts,
92739275
ndarray[int64_t, ndim=2] values,

0 commit comments

Comments
 (0)