[Numpy-svn] r6235 - in trunk: . numpy/core/tests
numpy-svn at scipy.org
numpy-svn at scipy.org
Mon Dec 29 02:57:56 EST 2008
Author: cdavid
Date: 2008-12-29 01:57:52 -0600 (Mon, 29 Dec 2008)
New Revision: 6235
Modified:
trunk/
trunk/numpy/core/tests/test_print.py
Log:
Merged revisions 6233-6234 via svnmerge from
http://svn.scipy.org/svn/numpy/branches/fix_float_format
........
r6233 | cdavid | 2008-12-29 12:49:09 +0900 (Mon, 29 Dec 2008) | 1 line
Use parametric tests for format tests so that it is clearer which type is failing.
........
r6234 | cdavid | 2008-12-29 12:49:27 +0900 (Mon, 29 Dec 2008) | 1 line
Fix formatting tests: cfloat and cdouble as well as np.float and np.double are the same; make sure we test 4 bytes float.
........
Property changes on: trunk
___________________________________________________________________
Name: svnmerge-integrated
- /branches/distutils-revamp:1-2752 /branches/dynamic_cpu_configuration:1-6101 /branches/fix_float_format:1-6222 /branches/multicore:1-3687 /branches/numpy-mingw-w64:1-6150 /branches/visualstudio_manifest:1-6077 /trunk:1-2871
+ /branches/distutils-revamp:1-2752 /branches/dynamic_cpu_configuration:1-6101 /branches/fix_float_format:1-6222,6233-6234 /branches/multicore:1-3687 /branches/numpy-mingw-w64:1-6150 /branches/visualstudio_manifest:1-6077 /trunk:1-2871
Modified: trunk/numpy/core/tests/test_print.py
===================================================================
--- trunk/numpy/core/tests/test_print.py 2008-12-29 03:49:27 UTC (rev 6234)
+++ trunk/numpy/core/tests/test_print.py 2008-12-29 07:57:52 UTC (rev 6235)
@@ -1,34 +1,37 @@
import numpy as np
from numpy.testing import *
-class TestPrint(TestCase):
+def check_float_type(tp):
+ for x in [0, 1,-1, 1e10, 1e20] :
+ assert_equal(str(tp(x)), str(float(x)))
- def test_float_types(self) :
- """ Check formatting.
+def test_float_types():
+ """ Check formatting.
- This is only for the str function, and only for simple types.
- The precision of np.float and np.longdouble aren't the same as the
- python float precision.
+ This is only for the str function, and only for simple types.
+ The precision of np.float and np.longdouble aren't the same as the
+ python float precision.
- """
- for t in [np.float, np.double, np.longdouble] :
- for x in [0, 1,-1, 1e10, 1e20] :
- assert_equal(str(t(x)), str(float(x)))
+ """
+ for t in [np.float32, np.double, np.longdouble] :
+ yield check_float_type, t
- def test_complex_types(self) :
- """Check formatting.
+def check_complex_type(tp):
+ for x in [0, 1,-1, 1e10, 1e20] :
+ assert_equal(str(tp(x)), str(complex(x)))
+ assert_equal(str(tp(x*1j)), str(complex(x*1j)))
+ assert_equal(str(tp(x + x*1j)), str(complex(x + x*1j)))
- This is only for the str function, and only for simple types.
- The precision of np.float and np.longdouble aren't the same as the
- python float precision.
+def test_complex_types():
+ """Check formatting.
- """
- for t in [np.cfloat, np.cdouble, np.clongdouble] :
- for x in [0, 1,-1, 1e10, 1e20] :
- assert_equal(str(t(x)), str(complex(x)))
- assert_equal(str(t(x*1j)), str(complex(x*1j)))
- assert_equal(str(t(x + x*1j)), str(complex(x + x*1j)))
+ This is only for the str function, and only for simple types.
+ The precision of np.float and np.longdouble aren't the same as the
+ python float precision.
+ """
+ for t in [np.complex64, np.cdouble, np.clongdouble] :
+ yield check_complex_type, t
if __name__ == "__main__":
run_module_suite()
More information about the Numpy-svn
mailing list