On Thu, Mar 29, 2012 at 13:47, Derek Homeier <[email protected]> wrote: > 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)
I don't recommend using that. Use np.issubdtype(a.dtype, np.integer) instead. -- Robert Kern _______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
