[Numpy-discussion] using scalar and tuple/list input on np.PyArray_MultiIterNew2
zoj613
blkzol001 at myuct.ac.za
Sun Jan 10 16:18:45 EST 2021
For what it's worth, I ended up defining a function like:
cdef np.broadcast broadcast(object a, object b):
"""
Broadcast the inputs into a multiIterator object.
the input can be a scalar, list, tuple or numpy array or array_like
object.
"""
cdef bint is_a_seq = is_sequence(h)
cdef bint is_a_seq = is_sequence(z)
h = <double>h if not is_a_seq else np.PyArray_FROM_OT(a, np.NPY_DOUBLE)
z = <double>z if not is_b_seq else np.PyArray_FROM_OT(b, np.NPY_DOUBLE)
return np.PyArray_MultiIterNew2(a, b)
It seems to do exactly what I want. Not sure if there are any potential bugs
that could result from this approach.
--
Sent from: http://numpy-discussion.10968.n7.nabble.com/
More information about the NumPy-Discussion
mailing list