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

numpy-svn at scipy.org numpy-svn at scipy.org
Mon Dec 29 03:02:18 EST 2008


Author: cdavid
Date: 2008-12-29 02:02:15 -0600 (Mon, 29 Dec 2008)
New Revision: 6236

Modified:
   trunk/numpy/core/tests/test_print.py
Log:
Add nan/inf tests for formatting.

Modified: trunk/numpy/core/tests/test_print.py
===================================================================
--- trunk/numpy/core/tests/test_print.py	2008-12-29 07:57:52 UTC (rev 6235)
+++ trunk/numpy/core/tests/test_print.py	2008-12-29 08:02:15 UTC (rev 6236)
@@ -16,6 +16,21 @@
     for t in [np.float32, np.double, np.longdouble] :
         yield check_float_type, t
 
+def check_nan_inf_float(tp):
+    for x in [float('inf'), float('-inf'), float('nan')]:
+        assert_equal(str(tp(x)), str(float(x)))
+
+def test_nan_inf_float():
+    """ 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.
+
+    """
+    for t in [np.float32, np.double, np.longdouble] :
+        yield check_nan_inf_float, t
+
 def check_complex_type(tp):
     for x in [0, 1,-1, 1e10, 1e20] :
         assert_equal(str(tp(x)), str(complex(x)))




More information about the Numpy-svn mailing list