@@ -175,32 +175,16 @@ cpdef dp2nd_array(arr):
175
175
""" Convert dparray to ndarray"""
176
176
return dpnp.asnumpy(arr) if isinstance (arr, dparray) else arr
177
177
178
- cdef long container_copy(dparray dst, input_obj , size_t dst_idx = 0 ) except - 1 :
179
- cdef elem_dtype = dst .dtype
178
+ cdef long container_copy(object dst_obj, object src_obj , size_t dst_idx = 0 ) except - 1 :
179
+ cdef elem_dtype = dst_obj .dtype
180
180
181
- for elem_value in input_obj :
181
+ for elem_value in src_obj :
182
182
if isinstance (elem_value, (list , tuple )):
183
- dst_idx = container_copy(dst , elem_value, dst_idx)
183
+ dst_idx = container_copy(dst_obj , elem_value, dst_idx)
184
184
elif issubclass (type (elem_value), (numpy.ndarray, dparray)):
185
- dst_idx = container_copy(dst , elem_value, dst_idx)
185
+ dst_idx = container_copy(dst_obj , elem_value, dst_idx)
186
186
else :
187
- if elem_dtype == numpy.float64:
188
- ( < double * > dst.get_data())[dst_idx] = elem_value
189
- elif elem_dtype == numpy.float32:
190
- ( < float * > dst.get_data())[dst_idx] = elem_value
191
- elif elem_dtype == numpy.int64:
192
- ( < long * > dst.get_data())[dst_idx] = elem_value
193
- elif elem_dtype == numpy.int32:
194
- ( < int * > dst.get_data())[dst_idx] = elem_value
195
- elif elem_dtype == numpy.bool_ or elem_dtype == numpy.bool:
196
- (< cpp_bool * > dst.get_data())[dst_idx] = elem_value
197
- elif elem_dtype == numpy.complex64:
198
- (< cpp_complex[float ] * > dst.get_data())[dst_idx] = elem_value
199
- elif elem_dtype == numpy.complex128:
200
- (< cpp_complex[double ] * > dst.get_data())[dst_idx] = elem_value
201
- else :
202
- checker_throw_type_error(" container_copy" , elem_dtype)
203
-
187
+ dst_obj.flat[dst_idx] = elem_value
204
188
dst_idx += 1
205
189
206
190
return dst_idx
0 commit comments