[Numpy-discussion] Different attributes for NumPy types

Robert Kern robert.kern at gmail.com
Thu May 22 15:59:00 EDT 2008


On Thu, May 22, 2008 at 2:46 PM, Charles R Harris
<charlesr.harris at gmail.com> wrote:
> It also leads to various inconsistencies:
>
> In [1]: float32(array([[1]]))
> Out[1]: array([[ 1.]], dtype=float32)
>
> In [2]: float64(array([[1]]))
> Out[2]: 1.0

Okay, so don't do that. Always use x.astype(dtype) or asarray(x, dtype).

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco



More information about the NumPy-Discussion mailing list