diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-01-20 13:16:51 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-01-20 13:27:12 -0700 |
commit | d55b5aa49d2ba1c98d568660b1a91b4b552872f0 (patch) | |
tree | 993137ac4786a69e8e56a7d6dd2396f16d57c71f /numpy | |
parent | e5f4f8283e7721b0a72b621b765c42d7d7866f4f (diff) | |
download | numpy-d55b5aa49d2ba1c98d568660b1a91b4b552872f0.tar.gz |
TST: Add test for printing of scalar values.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/tests/test_scalarprint.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/numpy/core/tests/test_scalarprint.py b/numpy/core/tests/test_scalarprint.py new file mode 100644 index 000000000..3bed7e62a --- /dev/null +++ b/numpy/core/tests/test_scalarprint.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +""" Test printing of scalar types. + +""" + +import numpy as np +from numpy.testing import TestCase, assert_, run_module_suite + + +class TestRealScalars(TestCase): + def test_str(self): + svals = [0.0, -0.0, 1, -1, np.inf, -np.inf, np.nan] + styps = [np.float16, np.float32, np.float64, np.longdouble] + actual = [str(f(c)) for c in svals for f in styps] + wanted = [ + '0.0', '0.0', '0.0', '0.0', + '-0.0', '-0.0', '-0.0', '-0.0', + '1.0', '1.0', '1.0', '1.0', + '-1.0', '-1.0', '-1.0', '-1.0', + 'inf', 'inf', 'inf', 'inf', + '-inf', '-inf', '-inf', '-inf', + 'nan', 'nan', 'nan', 'nan'] + + for res, val in zip(actual, wanted): + assert_(res == val) + + +if __name__ == "__main__": + run_module_suite() |