[Numpy-discussion] comparing string array with None raises ValueError

Rick White rlw at stsci.edu
Thu Jun 24 11:54:05 CDT 2004

On 24 Jun 2004, Todd Miller wrote:

> OK,  I see your point.  I talked it over with Perry and he made a
> reasonable case for allowing comparisons with None (or any object).
> Perry argued that since None is a common default parameter value, it
> might simplify code to not have to add logic to handle that case.
> If no one objects,  I'll change numarray.strings so that comparison of a
> string array with any object not convertible to a string array results
> in an array of False values.
> Any objections?

Hmm, before you do that you might look at this:

    >>> import numarray
    >>> b = numarray.zeros(10)
    >>> b==0
    array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1], type=Bool)
    >>> b==None

So comparing numeric arrays to None returns a scalar false value since
the variable b is not None.

I figure that the behavior of comparisons to None for string arrays and
numeric arrays ought to be consistent.  I don't know which is

More information about the Numpy-discussion mailing list