[SciPy-Dev] why this not report an error for a.dtype=float when a is mixed struc array

Vincent Davis vincent@vincentdavis....
Sat Jun 5 10:49:09 CDT 2010

On Sat, Jun 5, 2010 at 9:20 AM, Skipper Seabold <jsseabold@gmail.com> wrote:
> On Sat, Jun 5, 2010 at 11:09 AM, Vincent Davis <vincent@vincentdavis.net> wrote:
>> 2010/6/5 Stéfan van der Walt <stefan@sun.ac.za>:
>>> On 4 June 2010 17:49, Vincent Davis <vincent@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 might find this thread helpful.  Especially, Chris's reply.
> http://thread.gmane.org/gmane.comp.python.numeric.general/32664/

Ok now I understand why, that is why the numbers are a mess but not
why it is a feature :) I guess I am try to think of why I would use
this. I might be completely wrong but if most users would expect a
different behavior and don't notice what is actually happening then
maybe there should be a warning and a different way to get the current


> Skipper
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev

More information about the SciPy-Dev mailing list