Re: [Numpy-discussion] ufuncs on user-defined types in numarray
![](https://secure.gravatar.com/avatar/e2eccf1773826049905a11f3f5c0e6a4.jpg?s=120&d=mm&r=g)
Thanks Konrad, I didn't realise this was possible. I should use it on my ErrorVal module <http://users.bigpond.net.au/gazzar/python.html>. Last time I tried (quite a while ago), numarray's object array support wasn't up to allowing me to port ErrorVal from Numeric. I don't think it matters since I don't know of anyone, besides me, who has tried using my module :-( but I thought I'd mention it for Todd's benefit since I'm one who could benefit from implementing it in numarray. Gary R. ----- Original Message ----- From: "Todd Miller" <jmiller@stsci.edu> To: konrad.hinsen@laposte.net Subject: Re: [Numpy-discussion] ufuncs on user-defined types in numarray Date: 17 Dec 2004 10:09:51 -0500
On Fri, 2004-12-17 at 08:31, konrad.hinsen@laposte.net wrote:
I am working on making ScientificPython (http://dirac.cnrs-orleans.fr/ScientificPython/) compatible with numarray. One problem I stumbled across is that one feature of Numeric seems to be absent from numarray: the possibility to call ufuncs with arguments of non-numeric types, leading to a corresponding method call.
As an illustration, the following example works fine with Numeric, but crashes with numarray:
from Numeric import sqrt #from numarray import sqrt
class DummyValue:
def __init__(self, string): self.string = string
def __str__(self): return self.string
def sqrt(self): return DummyValue('sqrt(%s)' % self.string)
x = DummyValue('x') print sqrt(x)
Is this a bug or a feature?
It's a missing feature.
Is there another way to make ufuncs work with user-defined classes and types?
Not that I know of. How critical a feature is it? Do you have a work around?
numarray ufunc handling is in flux as I'm adding numarray support to scipy. At some point, there's going to be a major ufunc consolidation, and perhaps I can add this additional feature then.
Regards, Todd
------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/ _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
-- ___________________________________________________________ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm
![](https://secure.gravatar.com/avatar/f351f66930a1449592dd11b288e95cb8.jpg?s=120&d=mm&r=g)
On 19.12.2004, at 07:37, Gary Ruben wrote:
I didn't realise this was possible. I should use it on my ErrorVal module <http://users.bigpond.net.au/gazzar/python.html>. Last time I tried (quite a
Indeed! You could then even have arrays of ErrorVal objects with no extra effort, at least as long as ErrorVal doesn't implement the sequence protocol (because then all the Numeric functions will silently convert them to arrays). Your module looks interesting. What does it do internally, interval arithmetic? Konrad.
![](https://secure.gravatar.com/avatar/faf9400121dca9940496a7473b1d8179.jpg?s=120&d=mm&r=g)
Hi Gary and Konrad, I filed a Numarray Enhancement Request on Source Forge for this feature. It's not clear if, when, or how it will be implemented but it won't be completely forgotten either. Regards, Todd On Sun, 2004-12-19 at 16:37 +1000, Gary Ruben wrote:
Thanks Konrad, I didn't realise this was possible. I should use it on my ErrorVal module <http://users.bigpond.net.au/gazzar/python.html>. Last time I tried (quite a while ago), numarray's object array support wasn't up to allowing me to port ErrorVal from Numeric. I don't think it matters since I don't know of anyone, besides me, who has tried using my module :-( but I thought I'd mention it for Todd's benefit since I'm one who could benefit from implementing it in numarray. Gary R.
----- Original Message ----- From: "Todd Miller" <jmiller@stsci.edu> To: konrad.hinsen@laposte.net Subject: Re: [Numpy-discussion] ufuncs on user-defined types in numarray Date: 17 Dec 2004 10:09:51 -0500
On Fri, 2004-12-17 at 08:31, konrad.hinsen@laposte.net wrote:
I am working on making ScientificPython (http://dirac.cnrs-orleans.fr/ScientificPython/) compatible with numarray. One problem I stumbled across is that one feature of Numeric seems to be absent from numarray: the possibility to call ufuncs with arguments of non-numeric types, leading to a corresponding method call.
As an illustration, the following example works fine with Numeric, but crashes with numarray:
from Numeric import sqrt #from numarray import sqrt
class DummyValue:
def __init__(self, string): self.string = string
def __str__(self): return self.string
def sqrt(self): return DummyValue('sqrt(%s)' % self.string)
x = DummyValue('x') print sqrt(x)
Is this a bug or a feature?
It's a missing feature.
Is there another way to make ufuncs work with user-defined classes and types?
Not that I know of. How critical a feature is it? Do you have a work around?
numarray ufunc handling is in flux as I'm adding numarray support to scipy. At some point, there's going to be a major ufunc consolidation, and perhaps I can add this additional feature then.
Regards, Todd
------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/ _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
participants (3)
-
Gary Ruben
-
konrad.hinsen@laposte.net
-
Todd Miller