summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2010-07-18 17:17:58 +0000
committerPauli Virtanen <pav@iki.fi>2010-07-18 17:17:58 +0000
commit1985497ddd1c179d5ae4b7ba061a8b8c5540f543 (patch)
tree553fb199cc298b6ac1c856f4ebdec3a1fa5f550a
parent84c8c655652ca8cca087aca0512521800e29f314 (diff)
downloadnumpy-1985497ddd1c179d5ae4b7ba061a8b8c5540f543.tar.gz
BUG: core: format 'nan' and 'inf' also in array repr by default (#1050)
-rw-r--r--numpy/core/arrayprint.py8
-rw-r--r--numpy/core/tests/test_arrayprint.py10
2 files changed, 14 insertions, 4 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py
index 934d08dc8..9b6d1c036 100644
--- a/numpy/core/arrayprint.py
+++ b/numpy/core/arrayprint.py
@@ -27,8 +27,8 @@ _summaryThreshold = 1000 # total items > triggers array summarization
_float_output_precision = 8
_float_output_suppress_small = False
_line_width = 75
-_nan_str = 'NaN'
-_inf_str = 'Inf'
+_nan_str = 'nan'
+_inf_str = 'inf'
if sys.version_info[0] >= 3:
from functools import reduce
@@ -59,9 +59,9 @@ def set_printoptions(precision=None, threshold=None, edgeitems=None,
Whether or not suppress printing of small floating point values
using scientific notation (default False).
nanstr : str, optional
- String representation of floating point not-a-number (default NaN).
+ String representation of floating point not-a-number (default nan).
infstr : str, optional
- String representation of floating point infinity (default Inf).
+ String representation of floating point infinity (default inf).
See Also
--------
diff --git a/numpy/core/tests/test_arrayprint.py b/numpy/core/tests/test_arrayprint.py
new file mode 100644
index 000000000..954869727
--- /dev/null
+++ b/numpy/core/tests/test_arrayprint.py
@@ -0,0 +1,10 @@
+import numpy as np
+from numpy.testing import *
+
+class TestArrayRepr(object):
+ def test_nan_inf(self):
+ x = np.array([np.nan, np.inf])
+ assert_equal(repr(x), 'array([ nan, inf])')
+
+if __name__ == "__main__":
+ run_module_suite()