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

Scott Sinclair scott.sinclair.za@gmail....
Tue Nov 9 05:43:44 CST 2010


2010/11/9 Jóan Petur Petersen <joanpeturpetersen@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