[Numpy-discussion] Stop program when getting a warning (invalid value encountered in sqrt)

Scott Sinclair scott.sinclair.za at gmail.com
Tue Nov 9 06:43:44 EST 2010


2010/11/9 Jóan Petur Petersen <joanpeturpetersen at gmail.com>:
> I have write quite a large program, but I occationally get the following
> warning message:
>
> Warning: invalid value encountered in sqrt
>
> Can I make the program stop instead of just giving a warning, so that I get
> a traceback to where it comes from?

I think np.seterr(invalid='raise') should do the trick.

Cheers,
Scott



More information about the NumPy-Discussion mailing list