Open jbrockmendel opened 2 years ago
Indeed, these should be added.
The current API for setting an individual item in NumPy is PyArray_SETITEM(arr, char *data_ptr, object value)
. Although internally, we now have PyArray_Pack
(since 1.19.x), and I think that is much better and should be exposed, but I have not done that yet. (The problem is that PyArray_SETITEM
cannot get casts right, reasonably – doesn't matter in a lot of cases, but it needs to be phased out eventually IMO.)
(It might actually be reasonable to modify PyArray_SETITEM
to bend it to the new API though...)
EDIT: To be clear, it seems that PyArray_SETITEM
is also missing from the pxd
The current API for setting an individual item in NumPy is
PyArray_SETITEM(arr, char *data_ptr, object value)
Assuming I can figure out how to cimport it despite it being missing from the pxd, how do i get char *data_ptr
from mi
?
@jbrockmendel the pointer is just PyArray_MultiIter_DATA(mi, i)
? The array is mainly needed to fetch the dtype
, but in this case I guess you have the arrays available, so that is fine.
The
__init__.pxd
file that downstream libraries use to access the numpy C API via cython has the old PyArray_IterNew etc but not the new NpyIter_New etc.It'd be nice to have the newer ones.
Side-note: it'd be really convenient to have a nicer API for getitem/setitem for cnp.flatiter and cnp.broadcast objects. At the moment doing a ND-compatible
out[i] = func(values[i])
requires: