[SciPy-Dev] why this not report an error for a.dtype=float when a is mixed struc array
Vincent Davis
vincent at vincentdavis.net
Sat Jun 5 11:09:01 EDT 2010
2010/6/5 Stéfan van der Walt <stefan at sun.ac.za>:
> On 4 June 2010 17:49, Vincent Davis <vincent at vincentdavis.net> wrote:
>> Is there a reason not to have this return an error.
>>>>> a1 = np.array([(1,3.3),(2,4.4)], dtype=[('a', int),('b', float)])
>>>>> a1
>> array([(1, 3.2999999999999998), (2, 4.4000000000000004)],
>> dtype=[('a', '<i8'), ('b', '<f8')])
>>>>> a1.dtype=float
>>>>> a1
>> array([ 4.94065646e-324, 3.30000000e+000, 9.88131292e-324,
>> 4.40000000e+000])
>
> This is a feature! Sometimes, it is handy to view the raw memory in
> different ways.
Out of curiosity how would I use this?
Thanks
Vincent
>
> You are probably looking for the "astype" method.
>
> Regards
> Stéfan
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev
>
More information about the SciPy-Dev
mailing list