diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-12-23 07:08:57 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-12-23 07:08:57 +0000 |
commit | 0b5b7b6897600c264e22283e3b18374f9704b26b (patch) | |
tree | 4d2c12b8b4827ca0f75ed7ced5b251147da5ad3b /numpy/core/arrayprint.py | |
parent | 77295888c6913b2bccaf69571fc97f87d211aa62 (diff) | |
download | numpy-0b5b7b6897600c264e22283e3b18374f9704b26b.tar.gz |
Fix-up boolean Formatting so that true and false line up.
Diffstat (limited to 'numpy/core/arrayprint.py')
-rw-r--r-- | numpy/core/arrayprint.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index f82f5ee21..390252368 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -122,6 +122,11 @@ def _leading_trailing(a): 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 @@ def _array2string(a, max_line_width, precision, suppress_small, separator=' ', 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 @@ def _array2string(a, max_line_width, precision, suppress_small, separator=' ', 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 @@ def _formatArray(a, format_function, rank, max_line_len, leading_items, trailing_items, summary_insert1 = 0, len(a), "" if rank == 1: - s = "" line = next_line_prefix for i in xrange(leading_items): |