nan, warning and error modes
Hi, I am developing some numpy code, which sometimes fail because of nan. This is likely to be due to some bad coding on my side, and as such any NaN is a bug for this particular piece of code. Is there a way to get a warning when the first Nan is detected in the code (or even a faulty assertion) ? It looks like there are some variables/functions related to that in numpy, but I didn't find any useful document on the matter, either in the numpy book nor on the scipy website. cheers, David
David Cournapeau wrote:
Hi,
I am developing some numpy code, which sometimes fail because of nan. This is likely to be due to some bad coding on my side, and as such any NaN is a bug for this particular piece of code. Is there a way to get a warning when the first Nan is detected in the code (or even a faulty assertion) ? It looks like there are some variables/functions related to that in numpy, but I didn't find any useful document on the matter, either in the numpy book nor on the scipy website.
seterr(invalid='warning') Described in section "9.1.4 Error Handling" of the _Guide to NumPy_ (dated 2006-12-07). -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
On 2/27/07, Robert Kern <robert.kern@gmail.com> wrote:
David Cournapeau wrote:
Hi,
I am developing some numpy code, which sometimes fail because of nan. This is likely to be due to some bad coding on my side, and as such any NaN is a bug for this particular piece of code. Is there a way to get a warning when the first Nan is detected in the code (or even a faulty assertion) ? It looks like there are some variables/functions related to that in numpy, but I didn't find any useful document on the matter, either in the numpy book nor on the scipy website.
seterr(invalid='warning')
Ahem. seterr(invalid='warn') -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
Robert Kern wrote:
David Cournapeau wrote:
Hi,
I am developing some numpy code, which sometimes fail because of nan. This is likely to be due to some bad coding on my side, and as such any NaN is a bug for this particular piece of code. Is there a way to get a warning when the first Nan is detected in the code (or even a faulty assertion) ? It looks like there are some variables/functions related to that in numpy, but I didn't find any useful document on the matter, either in the numpy book nor on the scipy website.
seterr(invalid='warning')
Described in section "9.1.4 Error Handling" of the _Guide to NumPy_ (dated 2006-12-07).
Well, my bad, even if I don't have this version, this section is present in my own version.... I looked at the wrong keywords, thank you, David
participants (2)
-
David Cournapeau
-
Robert Kern