
Hey again! Why is (arange(2, typecode=Complex) % 2).typecode() object and not complex? Jean-Bernard Python 1.5.1 (#1, Dec 17 1998, 20:58:15) [GCC 2.7.2.3] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Hello from .pythonrc.py
from Numeric import * (arange(2, typecode=Complex) % 2).typecode() 'O' arange(2, typecode=Complex) % 2 array([0j , (1+0j) ],'O') arange(2) % 2 array([0, 1])
I have the same result python 1.5.2 and Numeric 11.

Jean-Bernard Addor writes:
Hey again!
Why is (arange(2, typecode=Complex) % 2).typecode() object and not complex?
Looks like a bug to me!
x=arange(2, typecode=Complex) x array([ 0.+0.j, 1.+0.j]) x+10 array([ 10.+0.j, 11.+0.j]) x*10 array([ 0.+0.j, 10.+0.j]) x/10 array([ 0. +0.j, 0.1+0.j]) x%10 array([0j , (1+0j) ],'O')
I don't see (offhand) why other operations leave the array as complex, and "%" causes it to be an 'O'. Presumably complex arrays lack the "mod" method and are getting promoted to Object. However, for float and double arrays you get the expected behavior:
x=arange(2, typecode=Float) x%10 array([ 0., 1.])
participants (2)
-
Charles G Waldman
-
Jean-Bernard Addor