[Numpy-discussion] dtype attribute missing in numarray
jmiller at stsci.edu
Thu Jan 5 10:26:20 CST 2006
Sebastian Haase wrote:
>I like this a lot. Maybe it could be mentioned in the documention - I don't
>have any good suggestions on where, I just noticed that 'dtype' is not in the
>I assume the following assignment to 'dtype' is not that important !?
>>>>a = na.arange(10,dtype=na.float32)
>>>>a.dtype = na.int32
>Traceback (most recent call last):
> File "<input>", line 1, in ?
>AttributeError: can't set attribute
Things are changing fast but I don't think this is supposed to work:
>>> import scipy
>>> a = scipy.arange(10)
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> a.dtype = scipy.int16
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: attribute 'dtype' of 'scipy.bigndarray' objects is not writable
My thinking was that you'd need a.astype() which returns a new array
object. Since types vary in size, it's not clear what it means to
assign type or how it would affect shape.
>Also: when / why was it decided that dtypes (float32, int32, ...) should be
>lowercase !? Aren't all python types usually uppercase ...
The naming looks clean to me. I don't know how the decision was made.
More information about the Numpy-discussion