On Fri, Sep 7, 2012 at 7:54 AM, Ralf Gommers <ralf.gommers@gmail.com> wrote:
On Wed, Sep 5, 2012 at 7:06 AM, Travis Oliphant <travis@continuum.io> wrote:
The framework for catching errors relies on hardware flags getting set and our C code making the right calls to detect those flags.
This has usually worked correctly in the past --- but it is an area where changes in compilers or platforms could create problems.
I don't think it ever did, for less common platforms at least. See all the Debian test issues that were filed by Sandro this week. And even between Windows and Linux, there are some inconsistencies.
We should test to be sure that the correct warnings are issued, I would think. Perhaps using a catch_warnings context would be helpful (from http://docs.python.org/library/warnings.html)
There are some tests for that already, in core/test_numeric.py. For example:
====================================================================== FAIL: test_default (test_numeric.TestSeterr) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/rgommers/Code/numpy/numpy/core/tests/test_numeric.py", line 231, in test_default under='ignore', AssertionError: {'over': 'ignore', 'divide': 'ignore', 'invalid': 'ignore', 'under': 'ignore'} != {'over': 'warn', 'divide': 'warn', 'invalid': 'warn', 'under': 'ignore'}
----------------------------------------------------------------------
They're not exhaustive though.
import warnings
def fxn(): warnings.warn("deprecated", DeprecationWarning)
with warnings.catch_warnings(record=True) as w: # Cause all warnings to always be triggered. warnings.simplefilter("always") # Trigger a warning. fxn() # Verify some things assert len(w) == 1 assert issubclass(w[-1].category, DeprecationWarning) assert "deprecated" in str(w[-1].message)
Use ``from numpy.testing import WarningManager`` for a 2.4-compatible version of catch_warnings (with explicitly calling its __enter__ and __exit__ methods).
In the release 1.7.x branch these warnings are suppressed, but in master they frequently make the Travis tests fail. That's extremely annoying to me, so I started working on a fix here: https://github.com/numpy/numpy/pull/2745 using the recommendation from Travis above. Ondrej