[Numpy-discussion] how to check type of array?

Olivier Delalleau shish at keba.be
Thu Mar 29 08:41:46 EDT 2012


if type(a) == numpy.ndarray:
   ...
if a.dtype == 'int32':
   ...

-=- Olivier

Le 29 mars 2012 07:54, Chao YUE <chaoyuejoy at gmail.com> a écrit :

> Dear all,
>
> how can I check type of array in if condition expression?
>
> In [75]: type(a)
> Out[75]: <type 'numpy.ndarray'>
>
> In [76]: a.dtype
> Out[76]: dtype('int32')
>
> a.dtype=='int32'?
>
> thanks!
>
> Chao
>
>
> --
>
> ***********************************************************************************
> Chao YUE
> Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
> UMR 1572 CEA-CNRS-UVSQ
> Batiment 712 - Pe 119
> 91191 GIF Sur YVETTE Cedex
> Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
>
> ************************************************************************************
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120329/a8ffc5bf/attachment.html>


More information about the NumPy-Discussion mailing list