[Numpy-discussion] How do I test if an array contains NaN ?

Keith Goodman kwgoodman at gmail.com
Thu Jan 4 18:24:27 EST 2007


On 1/4/07, Sebastian Haase <seb.haase at gmx.net> wrote:
> On 1/4/07, Keith Goodman <kwgoodman at gmail.com> wrote:
> > On 1/4/07, Sebastian Haase <haase at msg.ucsf.edu> wrote:
> > > How do I test if an array contains NaN ?
> > > Or others like inf ...?
> >
> > isnan()
> > ~isfinite()
> > any()
>
> Aah ! thanks,
> you mean I have to create an intermediate array that tells me for
> every element if is's a nan
> and then check any( ... ) on this !?
>
> That's OK for what I need -- seems excessive for large arrays though ....

Would this save memory?

isnan(x.sum())



More information about the NumPy-Discussion mailing list