diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2008-07-12 21:46:29 +0000 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2008-07-12 21:46:29 +0000 |
commit | 6748d60d650d0b2383c62ae076aec799c0f8fda3 (patch) | |
tree | 3d9810b2ff49759bc96d253e6abec788dfd54115 /numpy | |
parent | 072d2e0f561612082097a1a7b880aa9ef01fed74 (diff) | |
download | numpy-6748d60d650d0b2383c62ae076aec799c0f8fda3.tar.gz |
Add basic tests of number str() formatting.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/tests/test_print.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/numpy/core/tests/test_print.py b/numpy/core/tests/test_print.py new file mode 100644 index 000000000..b4b12048a --- /dev/null +++ b/numpy/core/tests/test_print.py @@ -0,0 +1,36 @@ +import numpy as np +from numpy.testing import * + +class TestPrint(TestCase): + + def test_float_types(self) : + """ 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.float, np.double, np.longdouble] : + for x in [0, 1,-1, 1e10, 1e20] : + assert_equal(str(t(x)), str(float(x))) + + def test_complex_types(self) : + """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.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))) + + + + +if __name__ == "__main__": + run_module_suite() |