I'm encountering FloatingPointError: invalid value encountered in subtract in a piece of test code. The exception started being raised without any changes being made in the code itself, so I'm having a great deal of trouble understanding it.
My question: What causes the invalid value encountered in subtract exception? Why would it behave differently on different installs of python+numpy?
DETAILS:
This MWE does not raise a FloatingPointError:
>>> import numpy as np
>>> np.__version__
'1.6.1'
>>> x = np.arange(5,dtype='float64')
>>> y = np.ones(5,dtype='float64')
>>> x[2]=np.nan
>>> x-y
# array([ -1., 0., nan, 2., 3.])
However, deep within a piece of code, I subtract two np.float64 ndarray objects, and get a floating point exception. The arrays causing the exception contain some pretty enormous and tiny numbers (e.g., 1e307 and 1e-307) and some nans, but I haven't made any combination of these numbers result in an exception testing on my own.
Much more disturbingly, I have a large grid of Jenkins tests running the exact same code with many versions of numpy, matplotlib, python, and scipy, and NONE of them raise this exception. I'm lost at this point - I don't know if there is a bug, or if there is, how to track it down.
In case you're morbidly curious, the code in question is pyspeckit and the test is failing on line 20 of test_hr2421.py.
EDIT: Follow-up - I think this little snippet: np.seterr(invalid='raise') was being called in a module I was importing, specifically pymc, and a pull request has since prevented this change from being made.