[Numpy-svn] r3320 - trunk/numpy/core/tests

numpy-svn at scipy.org numpy-svn at scipy.org
Thu Oct 12 14:29:15 CDT 2006


Author: tim_hochberg
Date: 2006-10-12 14:29:12 -0500 (Thu, 12 Oct 2006)
New Revision: 3320

Added:
   trunk/numpy/core/tests/test_errstate.py
Log:
Forgot this file in last commit:

Added docstring and tests to errstate. Also added 'all' option for seterr so that we can set all the options at once. Note that tests on errstate are only run in Python 2.5 and higher.




Added: trunk/numpy/core/tests/test_errstate.py
===================================================================
--- trunk/numpy/core/tests/test_errstate.py	2006-10-12 19:19:04 UTC (rev 3319)
+++ trunk/numpy/core/tests/test_errstate.py	2006-10-12 19:29:12 UTC (rev 3320)
@@ -0,0 +1,45 @@
+#~ import sys
+#~ if sys.version_info[:2] >= (2, 5):
+    #~ exec """
+from __future__ import with_statement
+from numpy.core import *
+from numpy.random import rand, randint
+from numpy.testing import *
+
+
+
+class test_errstate(NumpyTestCase):
+
+    
+    def test_invalid(self):
+        with errstate(all='raise', under='ignore'):
+            a = -arange(3)
+            # This should work
+            with errstate(invalid='ignore'):
+                sqrt(a)
+            # While this should fail!
+            try:
+                sqrt(a)
+            except FloatingPointError:
+                pass
+            else:
+                self.fail()
+                
+    def test_divide(self):
+        with errstate(all='raise', under='ignore'):
+            a = -arange(3)
+            # This should work
+            with errstate(divide='ignore'):
+                a / 0
+            # While this should fail!
+            try:
+                a / 0
+            except FloatingPointError:
+                pass
+            else:
+                self.fail()
+#~ """
+
+if __name__ == '__main__':
+    from numpy.testing import *
+    NumpyTest().run()
\ No newline at end of file



More information about the Numpy-svn mailing list