Numeric and output args for logical comparison ufuncs

Jeremy Biddle beeduul at yahoo.com
Fri Mar 5 13:57:52 EST 2004


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



More information about the Python-list mailing list