On Mon, May 4, 2009 at 3:55 PM, David Warde-Farley dwf@cs.toronto.eduwrote:

Hi,

Is there a simple way to compare each element of an object array to a single object? objarray == None, for example, gives me a single "False". I couldn't find any reference to it in the documentation, but I'll admit, I wasn't quite sure where to look.

I think it might depend on some factors:

In [1]: a = np.array(['a','b'], dtype=np.object)

In [2]: a=='a' Out[2]: array([ True, False], dtype=bool)

In [3]: a==None Out[3]: False

In [4]: a == [] Out[4]: False

In [5]: a == '' Out[5]: array([False, False], dtype=bool)

In [6]: a == dict() Out[6]: array([False, False], dtype=bool)

In [7]: numpy.__version__ Out[7]: '1.4.0.dev6885'

In [8]: a == 5 Out[8]: array([False, False], dtype=bool)

In [9]: a == 5. Out[9]: array([False, False], dtype=bool)

But based on these results, I have no idea what the factors might be. I know this works with datetime objects, but I'm really not sure why None and the empty list don't work.

Ryan