@@ -68,12 +68,12 @@ cpdef map_indices_{{name}}(ndarray[{{c_type}}] index):
68
68
69
69
@cython.boundscheck(False)
70
70
@cython.wraparound(False)
71
- def pad_{{name}}(ndarray[{{c_type}}] old, ndarray[{{c_type}}] new,
72
- limit=None) :
73
- cdef Py_ssize_t i, j, nleft, nright
74
- cdef ndarray[int64_t, ndim=1] indexer
75
- cdef {{c_type}} cur, next
76
- cdef int lim, fill_count = 0
71
+ def pad_{{name}}(ndarray[{{c_type}}] old, ndarray[{{c_type}}] new, limit=None):
72
+ cdef :
73
+ Py_ssize_t i, j, nleft, nright
74
+ ndarray[int64_t, ndim=1] indexer
75
+ {{c_type}} cur, next
76
+ int lim, fill_count = 0
77
77
78
78
nleft = len(old)
79
79
nright = len(new)
@@ -135,9 +135,10 @@ def pad_{{name}}(ndarray[{{c_type}}] old, ndarray[{{c_type}}] new,
135
135
def pad_inplace_{{name}}(ndarray[{{c_type}}] values,
136
136
ndarray[uint8_t, cast=True] mask,
137
137
limit=None):
138
- cdef Py_ssize_t i, N
139
- cdef {{c_type}} val
140
- cdef int lim, fill_count = 0
138
+ cdef:
139
+ Py_ssize_t i, N
140
+ {{c_type}} val
141
+ int lim, fill_count = 0
141
142
142
143
N = len(values)
143
144
@@ -171,9 +172,10 @@ def pad_inplace_{{name}}(ndarray[{{c_type}}] values,
171
172
def pad_2d_inplace_{{name}}(ndarray[{{c_type}}, ndim=2] values,
172
173
ndarray[uint8_t, ndim=2] mask,
173
174
limit=None):
174
- cdef Py_ssize_t i, j, N, K
175
- cdef {{c_type}} val
176
- cdef int lim, fill_count = 0
175
+ cdef:
176
+ Py_ssize_t i, j, N, K
177
+ {{c_type}} val
178
+ int lim, fill_count = 0
177
179
178
180
K, N = (<object> values).shape
179
181
233
235
@cython.wraparound(False)
234
236
def backfill_{{name}}(ndarray[{{c_type}}] old, ndarray[{{c_type}}] new,
235
237
limit=None):
236
- cdef Py_ssize_t i, j, nleft, nright
237
- cdef ndarray[int64_t, ndim=1] indexer
238
- cdef {{c_type}} cur, prev
239
- cdef int lim, fill_count = 0
238
+ cdef:
239
+ Py_ssize_t i, j, nleft, nright
240
+ ndarray[int64_t, ndim=1] indexer
241
+ {{c_type}} cur, prev
242
+ int lim, fill_count = 0
240
243
241
244
nleft = len(old)
242
245
nright = len(new)
@@ -299,9 +302,10 @@ def backfill_{{name}}(ndarray[{{c_type}}] old, ndarray[{{c_type}}] new,
299
302
def backfill_inplace_{{name}}(ndarray[{{c_type}}] values,
300
303
ndarray[uint8_t, cast=True] mask,
301
304
limit=None):
302
- cdef Py_ssize_t i, N
303
- cdef {{c_type}} val
304
- cdef int lim, fill_count = 0
305
+ cdef:
306
+ Py_ssize_t i, N
307
+ {{c_type}} val
308
+ int lim, fill_count = 0
305
309
306
310
N = len(values)
307
311
@@ -335,9 +339,10 @@ def backfill_inplace_{{name}}(ndarray[{{c_type}}] values,
335
339
def backfill_2d_inplace_{{name}}(ndarray[{{c_type}}, ndim=2] values,
336
340
ndarray[uint8_t, ndim=2] mask,
337
341
limit=None):
338
- cdef Py_ssize_t i, j, N, K
339
- cdef {{c_type}} val
340
- cdef int lim, fill_count = 0
342
+ cdef:
343
+ Py_ssize_t i, j, N, K
344
+ {{c_type}} val
345
+ int lim, fill_count = 0
341
346
342
347
K, N = (<object> values).shape
343
348
@@ -428,10 +433,10 @@ def is_monotonic_{{name}}(ndarray[{{c_type}}] arr, bint timelike):
428
433
@cython.wraparound(False)
429
434
@cython.boundscheck(False)
430
435
def arrmap_{{name}}(ndarray[{{c_type}}] index, object func):
431
- cdef Py_ssize_t length = index.shape[0]
432
- cdef Py_ssize_t i = 0
433
-
434
- cdef ndarray[object] result = np.empty(length, dtype=np.object_)
436
+ cdef:
437
+ Py_ssize_t length = index.shape[0]
438
+ Py_ssize_t i = 0
439
+ ndarray[object] result = np.empty(length, dtype=np.object_)
435
440
436
441
from pandas._libs.lib import maybe_convert_objects
437
442
@@ -535,6 +540,7 @@ def put2d_{{name}}_{{dest_type}}(ndarray[{{c_type}}, ndim=2, cast=True] values,
535
540
536
541
cdef int PLATFORM_INT = (<ndarray> np.arange(0, dtype=np.intp)).descr.type_num
537
542
543
+
538
544
cpdef ensure_platform_int(object arr):
539
545
# GH3033, GH1392
540
546
# platform int is the size of the int pointer, e.g. np.intp
@@ -546,6 +552,7 @@ cpdef ensure_platform_int(object arr):
546
552
else:
547
553
return np.array(arr, dtype=np.intp)
548
554
555
+
549
556
cpdef ensure_object(object arr):
550
557
if util.is_array(arr):
551
558
if (<ndarray> arr).descr.type_num == NPY_OBJECT:
0 commit comments