On 19/09/2007, Travis E. Oliphant <[EMAIL PROTECTED]> wrote: > Anne Archibald wrote: > > vectorize, of course, is a good example of my point above: it really > > just loops, in python IIRC, but conceptually it's extremely handy for > > doing exactly what the OP wanted. Unfortunately vectorize() does not > > yield a sufficiently ufunc-like object to support .outer(), as that > > would be extremely tidy. > > > I'm not sure what you mean by sufficiently ufunc-like. In fact, > vectorize is a ufunc (it's just an object-based one). Thus, it should > produce what you want (as long as you use newaxis so that the > broadcasting is done). If you just want it to support the .outer > method that could be easily done (as under the covers is a real ufunc). > > I just over-looked adding these methods to the result of vectorize. > The purpose of vectorize is to create a ufunc out of a scalar-based > function, so I don't see any problem in giving them the methods of > ufuncs as well (as long as the signature is right --- 2 inputs and 1 > output).
Ah. You got it in one: I was missing the methods. It would be handy to have them back, not least because then I could just remember the rule "all binary ufuncs have .outer()". Do ternary ufuncs support outer()? It would presumably just generate a higher-rank array, for example U.outer(arange(10),arange(11),arange(12)) would produce an array of shape (10,11,12)... maybe there aren't any ternary ufuncs yet, apart from the ones that are generated by vectorize(). I suppose ix_ provides an alternative, so that you could have def outer(self,*args): return self(ix_(*args)) Still, I think for conceptual tidiness it would be nice if the ufuncs vectorize() makes supported the methods. Thanks, Anne _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion