[Numpy-discussion] isarray in numpy?

Eric Firing efiring@hawaii....
Fri Mar 30 12:33:57 CDT 2007

Travis Oliphant wrote:
> mark wrote:
>> Is there a way to check whether something is an array?
>> It seems that
> isinstance(a, numpy.ndarray)
> This will return True if a is an array or a sub-class. 

Watch out if you use numpy.ma; or use Pierre G-M's maskedarray instead 
(assuming you want a masked array to be identified as an array):

In [1]:import numpy as N

In [2]:xx = N.ma.array([1,2,3])

In [3]:isinstance(xx, N.ndarray)

In [4]:import maskedarray as MA

In [5]:yy = MA.array([1,2,3])

In [6]:isinstance(yy, N.ndarray)


> -Travis
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion

More information about the Numpy-discussion mailing list