[Numpy-discussion] numarray bug !? astype with 2d array gives transform ??

Sebastian Haase haase at msg.ucsf.edu
Thu Oct 9 10:26:10 CDT 2003


Hi !
I just discovered this: (I'm using numarray 0.6 [on windows])

>>> dy = na.fromfunction(lambda y,x: y, (3,3))
>>> dx = na.fromfunction(lambda y,x: x, (3,3))
>>> dy
array([[0, 0, 0],
       [1, 1, 1],
       [2, 2, 2]])
>>> dx
array([[0, 1, 2],
       [0, 1, 2],
       [0, 1, 2]])
>>> dx.type()
Int32
>>> dx.astype(na.Int8)
array([[0, 0, 0],
       [1, 1, 1],
       [2, 2, 2]], type=Int8)
>>> dx.astype(na.Int16)
array([[0, 0, 0],
       [1, 1, 1],
       [2, 2, 2]], type=Int16)
>>> dx.astype(na.Float)
array([[ 0.,  0.,  0.],
       [ 1.,  1.,  1.],
       [ 2.,  2.,  2.]])
>>> dx.astype(na.Float32)
array([[ 0.,  0.,  0.],
       [ 1.,  1.,  1.],
       [ 2.,  2.,  2.]], type=Float32)

What does this mean ? Am I missing something ?

Thanks,
Sebastian Haase





More information about the Numpy-discussion mailing list