[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Q about Numeric, ufuncs, output args
This problem appears to be solved in numarray, but since we're stuck
with Numeric for the time being I thought I would ask this here (I
originally posted it to comp.lang.python) as well.
Has anyone used Numeric and figured out how to get around this?
----
hi, I haven't been able to resolve this problem, the docs were not
explicit enough and a search hasn't yielded a resolution so I'm
posting for some help.
I'm using Numeric to do some array calculations on Int8 arrays, but
the results of the logical comparison ufuncs return 32-bit ints and so
are incompatible with my data set. (btw, I'm using pygame so I can't
move to numarray -- not sure whether that would solve the problem
anyway...)
Here's an illustration of the problem --
>>> import Numeric as N
>>> a = N.zeros((5,5), N.Int8)
>>> N.equal(a,0,a)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: return array has incorrect type
I know I can do this:
>>> a = N.zeros((5,5), N.Int8)
>>> a = N.equal(a,0).astype(N.Int8)
...but I want to do an in-place operation (using output args) to save
time and space.
Is there any way to tell the ufunc to use Int8s instead of Int32s (or
64s or whatever)??
Thanks,
Jeremy