[Numpy-svn] r3489 - trunk/numpy/core

numpy-svn at scipy.org numpy-svn at scipy.org
Sat Dec 23 02:09:10 EST 2006


Author: oliphant
Date: 2006-12-23 01:08:57 -0600 (Sat, 23 Dec 2006)
New Revision: 3489

Modified:
   trunk/numpy/core/arrayprint.py
Log:
Fix-up boolean Formatting so that true and false line up.

Modified: trunk/numpy/core/arrayprint.py
===================================================================
--- trunk/numpy/core/arrayprint.py	2006-12-23 06:37:39 UTC (rev 3488)
+++ trunk/numpy/core/arrayprint.py	2006-12-23 07:08:57 UTC (rev 3489)
@@ -122,6 +122,11 @@
         b = _gen.concatenate(tuple(l))
     return b
 
+def _boolFormatter(x):
+    if x: return ' True'
+    else: return 'False'
+    
+
 def _array2string(a, max_line_width, precision, suppress_small, separator=' ',
                   prefix=""):
 
@@ -145,10 +150,10 @@
         format_function = a._format
     except AttributeError:
         dtypeobj = a.dtype.type
-        if issubclass(dtypeobj, _nt.bool):
-            format = "%s"
-            format_function = lambda x: format % x
-        if issubclass(dtypeobj, _nt.integer):
+        if issubclass(dtypeobj, _nt.bool_):
+            # make sure True and False line up.
+            format_function = _boolFormatter
+        elif issubclass(dtypeobj, _nt.integer):
             max_str_len = max(len(str(max_reduce(data))),
                               len(str(min_reduce(data))))
             format = '%' + str(max_str_len) + 'd'
@@ -180,7 +185,6 @@
     next_line_prefix = " " # skip over "["
     next_line_prefix += " "*len(prefix)                  # skip over array(
 
-
     lst = _formatArray(a, format_function, len(a.shape), max_line_width,
                        next_line_prefix, separator,
                        _summaryEdgeItems, summary_insert)[:-1]
@@ -248,7 +252,6 @@
         leading_items, trailing_items, summary_insert1 = 0, len(a), ""
 
     if rank == 1:
-
         s = ""
         line = next_line_prefix
         for i in xrange(leading_items):




More information about the Numpy-svn mailing list