summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/tests/test_scalarprint.py29
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()