[Numpy-discussion] Scalar array - a trap for the unwary

Francesc Altet faltet at carabos.com
Tue Jan 24 01:44:04 EST 2006


A Dilluns 23 Gener 2006 23:31, Colin J. Williams va escriure:
>  >>> a= _mu.array([1, 2], dtype= _nt.uint8)
>  >>> a+254
>
> array([255, 256], dtype=int16)
>
> This does bring out a possible problem with the new type.  str of the
> old type returned the input name int8, float64 etc.  Is there some
> method of the new type which returns the name input, 'int8' in the above
> example?  In most cases, the mnemonic is more helpful than the letter
> coding.

Yes. a.dtype.name does the trick.

Cheers,

-- 
>0,0<   Francesc Altet     http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data
 "-"





More information about the NumPy-Discussion mailing list