
I am trying to use objects in an array, and still be able to use the various extra functions offered by multiarray. I am finding that some of the functions work and some don't. Is it hopeless to try to use objects in an array and expect <op>.reduce and others to work properly? As a simple example, I have a DataPoint object that consists of a value and flag(s). This object has all the __cmp__, __add_, etc functions implemented. I can do MA.average(m), MA.sum(m), MA.add.reduce(m), (they seem to use __add__) but I can't do MA.minimum.reduce(m) or MA.maximum.reduce(m). I can do MA.maximum(m) and MA.minimum(m), but not MA.maximum(m, 0) or MA.minimum(m, 0) The values returned by MA.argmax(m) makes no sense (wrong index?) but is consistent with results from argsort(). MA.argmin(m) gives an error (I have a __neg__ fn in datapoint) File "C:\Python21\MA\MA.py", line 1977, in argmin return Numeric.argmin(d, axis) File "C:\Python21\Numeric\Numeric.py", line 281, in argmin a = -array(a, copy=0) TypeError: bad operand type for unary - for example: print m # 3 valid, 1 masked print MA.maximum(m) print MA.argmax(m) # gives index to masked value print MA.minimum(m) #print MA.argmin(m) - gives error above print MA.argsort(m) print MA.average(m) print MA.maximum.reduce(m, 0) [1, ] ,[10, a] ,[None, D] ,-- ,] [10, a] 3 [None, D] [2,0,1,3,] [3.66666666667, aD] Traceback (most recent call last): File "C:\Python21\Pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript exec codeObject in __main__.__dict__ File "C:\Python21\HDP\Data\DataPoint.py", line 136, in ? print MA.maximum.reduce(m, 0) File "C:\Python21\MA\MA.py", line 1913, in reduce t = Numeric.maximum.reduce(filled(target, maximum_fill_value(target)), axis) TypeError: function not supported for these types, and can't coerce to supported types

This is actually, very helpful information. I'm not sure how well-tested the object-type is with Numeric. I know it has been used, but I'm not sure all of the ufunc methods have been well tested. However, I'm not sure what is caused by MA and what is caused by basic Numeric, however. -Travis

This is actually, very helpful information. I'm not sure how well-tested the object-type is with Numeric. I know it has been used, but I'm not sure all of the ufunc methods have been well tested. However, I'm not sure what is caused by MA and what is caused by basic Numeric, however. -Travis
participants (2)
-
sag@hydrosphere.com
-
Travis Oliphant