Numeric and output args for logical comparison ufuncs

Discussion in 'Python' started by Jeremy Biddle, Mar 5, 2004.

  1. 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
    Jeremy Biddle, Mar 5, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken Varn
    Replies:
    2
    Views:
    612
    Ken Varn
    Jun 22, 2005
  2. Replies:
    3
    Views:
    480
    David Eppstein
    Sep 17, 2003
  3. Curzio Basso
    Replies:
    4
    Views:
    344
    Tim Hochberg
    Mar 4, 2004
  4. er
    Replies:
    2
    Views:
    485
  5. Deepu
    Replies:
    1
    Views:
    217
    ccc31807
    Feb 7, 2011
Loading...

Share This Page