[Numpy-svn] r5893 - branches/ufunc_cleanup/numpy/testing

numpy-svn@scip... numpy-svn@scip...
Thu Oct 2 21:11:52 CDT 2008


Author: charris
Date: 2008-10-02 21:11:50 -0500 (Thu, 02 Oct 2008)
New Revision: 5893

Modified:
   branches/ufunc_cleanup/numpy/testing/utils.py
Log:
Add assert_ to testing module. Use as assert_(condition, message).
This function does not disappear when python runs with the -OO option.


Modified: branches/ufunc_cleanup/numpy/testing/utils.py
===================================================================
--- branches/ufunc_cleanup/numpy/testing/utils.py	2008-10-03 02:04:10 UTC (rev 5892)
+++ branches/ufunc_cleanup/numpy/testing/utils.py	2008-10-03 02:11:50 UTC (rev 5893)
@@ -8,14 +8,19 @@
 import operator
 from nosetester import import_nose
 
-__all__ = ['assert_equal', 'assert_almost_equal','assert_approx_equal',
-           'assert_array_equal', 'assert_array_less', 'assert_string_equal',
-           'assert_array_almost_equal', 'assert_raises', 'build_err_msg',
-           'decorate_methods', 'jiffies', 'memusage', 'print_assert_equal',
-           'raises', 'rand', 'rundocs', 'runstring', 'verbose']
+__all__ = ['assert_', 'assert_equal', 'assert_almost_equal',
+           'assert_approx_equal', 'assert_array_equal', 'assert_array_less',
+           'assert_string_equal', 'assert_array_almost_equal', 'assert_raises',
+           'build_err_msg', 'decorate_methods', 'jiffies', 'memusage',
+           'print_assert_equal', 'raises', 'rand', 'rundocs', 'runstring',
+           'verbose']
 
 verbose = 0
 
+def assert_(test, message=""):
+    if not test:
+        raise AssertionError(message)
+
 def rand(*args):
     """Returns an array of random numbers with the given shape.
 



More information about the Numpy-svn mailing list