[SciPy-user] isnotnan

Pierre GM pgmdevlist@gmail....
Thu Feb 12 17:41:38 CST 2009


On Feb 12, 2009, at 6:37 PM, Christopher Brown wrote:

> Hi Padraic,
>
> PS> Is there a isnotnan function somewhere in the numpy or scipy  
> library
> PS>  that functions similarly to isnan (except that the results are
> PS> reversed)?
>
> I don't understand. Will 'not numpy.isnan' not work?

Can't work: "not" works on booleans, not on arrays, and np.isnan  
returns a ndarray of booleans. You end up raising a ValueError  
exception:
 >>>  x = np.array([1,np.nan,3.])
 >>> not np.isnan(x)
ValueError: The truth value of an array with more than one element is  
ambiguous. Use a.any() or a.all()

Just use np.logical_not.


More information about the SciPy-user mailing list