[Numpy-discussion] Runtime Warning by numpy.divide(0.0, 0.0) can't be ignored
Lorenzo Di Gregorio
lorenzo.digregorio at gmail.com
Mon Sep 23 05:43:33 EDT 2013
Hello,
numpy.divide(0.0,0.0) raises a warning which doesn't appear to get caught
by numpy.seterr(divide='ignore')
This example:
import numpy
numpy.divide(0.0,0.0)
numpy.divide(1.0,0.0)
numpy.seterr(divide='ignore')
numpy.divide(1.0,0.0)
numpy.divide(0.0,0.0)
produces this output:
Warning (from warnings module):
File "C:\Users\ldigrego\Desktop\tst.py", line 2
numpy.divide(0.0,0.0)
RuntimeWarning: invalid value encountered in divide
Warning (from warnings module):
File "C:\Users\ldigrego\Desktop\tst.py", line 3
numpy.divide(1.0,0.0)
RuntimeWarning: divide by zero encountered in divide
Warning (from warnings module):
File "C:\Users\ldigrego\Desktop\tst.py", line 6
numpy.divide(0.0,0.0)
RuntimeWarning: invalid value encountered in divide
Strangely, on Ipython the numpy.seterr(divide='ignore') seems to catch the
warning:
import numpy
numpy.divide(0.0,0.0)
Out[1]: nan
C:\eclipse\plugins\org.python.pydev_2.8.1.2013072611\pysrc\pydevconsole.py:1:
RuntimeWarning: invalid value encountered in divide
from __future__ import nested_scopes #Jython 2.1 support
numpy.divide(1.0,0.0)
Out[1]: inf
C:\eclipse\plugins\org.python.pydev_2.8.1.2013072611\pysrc\pydevconsole.py:1:
RuntimeWarning: divide by zero encountered in divide
from __future__ import nested_scopes #Jython 2.1 support
numpy.seterr(divide='ignore')
Out[1]: {'divide': 'warn', 'invalid': 'warn', 'over': 'warn', 'under':
'ignore'}
numpy.divide(1.0,0.0)
Out[1]: inf
numpy.divide(0.0,0.0)
Out[1]: nan
I could not find information on Google: is this a known problem? Is there
a way to suppress this warning?
I'm working on a 64b Win7 machine employing
numpy-MKL-1.7.0.win-amd64-py2.7.exe.
Best Regards,
Lorenzo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20130923/09069ec6/attachment.html>
More information about the NumPy-Discussion
mailing list