[Numpy-discussion] array multiplication with different dtypes
Sun Mar 25 04:03:17 CDT 2007
I'm having a difficult time understanding the following behavior:
import numpy as N
# create a new array 4 rows, 3 columns
x = N.random.random((4, 3))
# elementwise multiplication
newtype = N.dtype([('x', N.float64), ('y', N.float64), ('z', N.float64)])
# interpret the array as an array of cartesian coordinates
x.dtype = newtype
--> TypeError: unsupported operand type(s) for *: 'numpy.ndarray' and '
So just by assigning names to the columns, I can't multiply the arrays any
Numpy itself still claims that x is an ndarray.
I hope this is a bug, because it would be really convenient if this still
worked after assigning names to columns.
What I really wanted to do was N.dot(x, x.T) to get the length of the
cartesian vectors, but (I think) this fails for the same reason.
Please tell me this is a bug ;-)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion