On 14/02/07, Wojciech Śmigaj <[EMAIL PROTECTED]> wrote: > Timothy Hochberg wrote: > > On 2/14/07, *Wojciech Śmigaj* <[EMAIL PROTECTED] > > <mailto:[EMAIL PROTECTED]>> wrote: > >> I have a question about the vectorize function. I'd like to use it to > >> create a vectorized version of a class method. I've tried the following > >> code: > >> > >> from numpy import * > >> > >> class X: > >> def func(self, n): > >> return 2 * n # example > >> func = vectorize(func)
The appropriate spelling for this, in modern pythons, is class X: @vectorize def func(self, n): return 2*n Not that it makes it work any better. There's no reason vectorize couldn't be made to do the Right Thing when handed (bound and unbound) methods, for example by examining X.func.im_self, X.func.im_class and X.func.im_func attributes. I can't imagine a situation where a method would want to be vectorized over its self parameter, or at least, not by default. Anne _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion