[SciPy-Dev] why this not report an error for a.dtype=float when a is mixed struc array
Stéfan van der Walt
stefan at sun.ac.za
Sat Jun 5 04:22:04 EDT 2010
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.
You are probably looking for the "astype" method.
Regards
Stéfan
More information about the SciPy-Dev
mailing list