@@ -68,12 +68,12 @@ cpdef map_indices_{{name}}(ndarray[{{c_type}}] index):
6868
6969@cython.boundscheck(False)
7070@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
7777
7878 nleft = len(old)
7979 nright = len(new)
@@ -135,9 +135,10 @@ def pad_{{name}}(ndarray[{{c_type}}] old, ndarray[{{c_type}}] new,
135135def pad_inplace_{{name}}(ndarray[{{c_type}}] values,
136136 ndarray[uint8_t, cast=True] mask,
137137 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
141142
142143 N = len(values)
143144
@@ -171,9 +172,10 @@ def pad_inplace_{{name}}(ndarray[{{c_type}}] values,
171172def pad_2d_inplace_{{name}}(ndarray[{{c_type}}, ndim=2] values,
172173 ndarray[uint8_t, ndim=2] mask,
173174 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
177179
178180 K, N = (<object> values).shape
179181
233235@cython.wraparound(False)
234236def backfill_{{name}}(ndarray[{{c_type}}] old, ndarray[{{c_type}}] new,
235237 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
240243
241244 nleft = len(old)
242245 nright = len(new)
@@ -299,9 +302,10 @@ def backfill_{{name}}(ndarray[{{c_type}}] old, ndarray[{{c_type}}] new,
299302def backfill_inplace_{{name}}(ndarray[{{c_type}}] values,
300303 ndarray[uint8_t, cast=True] mask,
301304 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
305309
306310 N = len(values)
307311
@@ -335,9 +339,10 @@ def backfill_inplace_{{name}}(ndarray[{{c_type}}] values,
335339def backfill_2d_inplace_{{name}}(ndarray[{{c_type}}, ndim=2] values,
336340 ndarray[uint8_t, ndim=2] mask,
337341 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
341346
342347 K, N = (<object> values).shape
343348
@@ -428,10 +433,10 @@ def is_monotonic_{{name}}(ndarray[{{c_type}}] arr, bint timelike):
428433@cython.wraparound(False)
429434@cython.boundscheck(False)
430435def 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_)
435440
436441 from pandas._libs.lib import maybe_convert_objects
437442
@@ -535,6 +540,7 @@ def put2d_{{name}}_{{dest_type}}(ndarray[{{c_type}}, ndim=2, cast=True] values,
535540
536541cdef int PLATFORM_INT = (<ndarray> np.arange(0, dtype=np.intp)).descr.type_num
537542
543+
538544cpdef ensure_platform_int(object arr):
539545 # GH3033, GH1392
540546 # platform int is the size of the int pointer, e.g. np.intp
@@ -546,6 +552,7 @@ cpdef ensure_platform_int(object arr):
546552 else:
547553 return np.array(arr, dtype=np.intp)
548554
555+
549556cpdef ensure_object(object arr):
550557 if util.is_array(arr):
551558 if (<ndarray> arr).descr.type_num == NPY_OBJECT:
0 commit comments