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/
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion

Reply via email to