[Numpy-discussion] Different attributes for NumPy types

Bruce Southey bsouthey@gmail....
Thu May 22 16:25:23 CDT 2008


On Thu, May 22, 2008 at 2:59 PM, Robert Kern <robert.kern@gmail.com> wrote:
> On Thu, May 22, 2008 at 2:46 PM, Charles R Harris
> <charlesr.harris@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
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>

So, should these return an error if the argument is an ndarray object,
a list or similar?
Otherwise, int, float and string type of arguments would be okay under
the assumption that people would like variable precision scalars.


Bruce


More information about the Numpy-discussion mailing list