Re: [Numpy-discussion] Vectorizing a class method

2007-02-14 Thread Wojciech Śmigaj
Tom Denniston wrote: > I don't know if this helps but you could use where to do the dispatch > between the two different formulas. Yes, that's a good idea. Thanks! Wojciech Smigaj ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://proje

Re: [Numpy-discussion] Vectorizing a class method

2007-02-14 Thread Wojciech Śmigaj
Anne Archibald wrote: > 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)

Re: [Numpy-discussion] Vectorizing a class method

2007-02-14 Thread Anne Archibald
On 14/02/07, Wojciech Śmigaj <[EMAIL PROTECTED]> wrote: > Timothy Hochberg wrote: > > On 2/14/07, *Wojciech Śmigaj* <[EMAIL PROTECTED] > > > wrote: > >> I have a question about the vectorize function. I'd like to use it to > >> create a vectorized version of a clas

Re: [Numpy-discussion] Vectorizing a class method

2007-02-14 Thread Tom Denniston
I don't know if this helps but you could use where to do the dispatch between the two different formulas. I don't know the answer to your original question however. On 2/14/07, Wojciech Śmigaj <[EMAIL PROTECTED]> wrote: > Timothy Hochberg wrote: > > On 2/14/07, *Wojciech Śmigaj* <[EMAIL PROTECTED

Re: [Numpy-discussion] Vectorizing a class method

2007-02-14 Thread Wojciech Śmigaj
Timothy Hochberg wrote: > On 2/14/07, *Wojciech Śmigaj* <[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: >> >>fro

Re: [Numpy-discussion] Vectorizing a class method

2007-02-14 Thread Timothy Hochberg
On 2/14/07, Wojciech Śmigaj <[EMAIL PROTECTED]> wrote: Hi, 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

[Numpy-discussion] Vectorizing a class method

2007-02-14 Thread Wojciech Śmigaj
Hi, 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) Now, when I dec