Hello all, numpy.vectorize is a very convenient way to build universal function from scalar functions, and handle broadcasting... A use case that is not handled is the generalization to functions already returning nd array:
For example: If foo(x,y) is a scalar function returning a array of dim k, it would be convenient to create a vectorized version of it, such that if the broadcasted shape of x and y has dimension d, then foo(x,y) returns a (d+k)-dimensional array. For example: # Example 1 x = array([1,2,3]) y = array([4,5,6]) # foo(x,y)[i] is equal to foo(x[i], y[i]), a vector of dim k, # Example 2 x = array([1,2,3]) y = array([4,5,6]) # foo(x,y[:, newaxis])[i,j] is equal to foo(x[i], y[j]), a vector of dim k, Does any one know if there is already a way to do this? Best, Sylvain
_______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
