@@ -80,9 +80,9 @@ def take_1d_%(name)s_%(dest)s(ndarray[%(c_type_in)s] values,
80
80
81
81
take_2d_axis0_template = """@cython.wraparound(False)
82
82
@cython.boundscheck(False)
83
- def take_2d_axis0_%(name)s_%(dest)s(ndarray[ %(c_type_in)s, ndim=2 ] values,
83
+ def take_2d_axis0_%(name)s_%(dest)s(%(c_type_in)s[:, : ] values,
84
84
ndarray[int64_t] indexer,
85
- ndarray[ %(c_type_out)s, ndim=2 ] out,
85
+ %(c_type_out)s[:, : ] out,
86
86
fill_value=np.nan):
87
87
cdef:
88
88
Py_ssize_t i, j, k, n, idx
@@ -127,9 +127,9 @@ def take_2d_axis0_%(name)s_%(dest)s(ndarray[%(c_type_in)s, ndim=2] values,
127
127
128
128
take_2d_axis1_template = """@cython.wraparound(False)
129
129
@cython.boundscheck(False)
130
- def take_2d_axis1_%(name)s_%(dest)s(ndarray[ %(c_type_in)s, ndim=2 ] values,
130
+ def take_2d_axis1_%(name)s_%(dest)s(%(c_type_in)s[:, : ] values,
131
131
ndarray[int64_t] indexer,
132
- ndarray[ %(c_type_out)s, ndim=2 ] out,
132
+ %(c_type_out)s[:, : ] out,
133
133
fill_value=np.nan):
134
134
cdef:
135
135
Py_ssize_t i, j, k, n, idx
@@ -143,34 +143,12 @@ def take_2d_axis1_%(name)s_%(dest)s(ndarray[%(c_type_in)s, ndim=2] values,
143
143
144
144
fv = fill_value
145
145
146
- IF %(can_copy)s:
147
- cdef:
148
- %(c_type_out)s *v
149
- %(c_type_out)s *o
150
-
151
- #GH3130
152
- if (values.strides[0] == out.strides[0] and
153
- values.strides[0] == sizeof(%(c_type_out)s) and
154
- sizeof(%(c_type_out)s) * n >= 256):
155
-
156
- for j from 0 <= j < k:
157
- idx = indexer[j]
158
- if idx == -1:
159
- for i from 0 <= i < n:
160
- out[i, j] = fv
161
- else:
162
- v = &values[0, idx]
163
- o = &out[0, j]
164
- memmove(o, v, <size_t>(sizeof(%(c_type_out)s) * n))
165
- return
166
-
167
- for j from 0 <= j < k:
168
- idx = indexer[j]
169
- if idx == -1:
170
- for i from 0 <= i < n:
146
+ for i from 0 <= i < n:
147
+ for j from 0 <= j < k:
148
+ idx = indexer[j]
149
+ if idx == -1:
171
150
out[i, j] = fv
172
- else:
173
- for i from 0 <= i < n:
151
+ else:
174
152
out[i, j] = %(preval)svalues[i, idx]%(postval)s
175
153
176
154
"""
0 commit comments