On 29 Mar 2012, at 13:54, Chao YUE wrote:
> 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'?
this and
a.dtype=='i4'
a.dtype==np.int32
all work. For a more general check (e.g. if it is any type of integer), you can
do
np.issubclass_(a.dtype.type, np.integer)
See also "help(np.subdtype)"
Cheers,
Derek
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion