Re: [Numpy-discussion] using numpy functions on an array of objects

2009-02-01 Thread Sebastian Walter
On Sun, Feb 1, 2009 at 12:24 AM, Robert Kern wrote: > On Sat, Jan 31, 2009 at 10:30, Sebastian Walter > wrote: >> Wouldn't it be nice to have numpy a little more generic? >> All that would be needed was a little check of the arguments. >> >> If I do: >> numpy.trace(4) >> shouldn't numpy be smart

Re: [Numpy-discussion] using numpy functions on an array of objects

2009-01-31 Thread Robert Kern
On Sat, Jan 31, 2009 at 10:30, Sebastian Walter wrote: > Wouldn't it be nice to have numpy a little more generic? > All that would be needed was a little check of the arguments. > > If I do: > numpy.trace(4) > shouldn't numpy be smart enough to regard the 4 as a 1x1 array? Why? It's not a 1x1 arr

Re: [Numpy-discussion] using numpy functions on an array of objects

2009-01-31 Thread Sebastian Walter
Wouldn't it be nice to have numpy a little more generic? All that would be needed was a little check of the arguments. If I do: numpy.trace(4) shouldn't numpy be smart enough to regard the 4 as a 1x1 array? numpy.sin(4) works! and if x = my_class(4) wouldn't it be nice if numpy.trace(x) would c

Re: [Numpy-discussion] using numpy functions on an array of objects

2009-01-30 Thread Robert Kern
On Fri, Jan 30, 2009 at 13:18, Christopher Barker wrote: > I think you want to subclass an ndarray here. It's a bit tricky to so, > but if you look in the wiki and these mailing list archives, you'll find > advise on how to do it. That still won't work. numpy.linalg.inv() simply does a particular

Re: [Numpy-discussion] using numpy functions on an array of objects

2009-01-30 Thread Christopher Barker
I think you want to subclass an ndarray here. It's a bit tricky to so, but if you look in the wiki and these mailing list archives, you'll find advise on how to do it. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R(206) 526-6959 voic

[Numpy-discussion] using numpy functions on an array of objects

2009-01-30 Thread Sebastian Walter
Hey, What is the best solution to get this code working? Anyone a good idea? -- test.py --- import numpy import numpy.linalg class afloat: def __init__(self,x): self.x = x def __add__(self,rhs):