diff options
| author | Eric Wieser <wieser.eric@gmail.com> | 2017-11-28 23:29:04 -0800 |
|---|---|---|
| committer | Eric Wieser <wieser.eric@gmail.com> | 2017-11-30 00:00:59 -0800 |
| commit | 6df0b6e2b79aad40715f933b561660f951693289 (patch) | |
| tree | 8200afcd39330e86bf9b76e5ae9caa4ad61a3ca0 /numpy/core/arrayprint.py | |
| parent | 88f8310d8c3049881f78883b70766867e9147177 (diff) | |
| download | numpy-6df0b6e2b79aad40715f933b561660f951693289.tar.gz | |
ENH: Strip trailing spaces and add newlines in truncated arrayprint
This is otherwise pretty strict about trailing spaces, so we may as well cut them here too, especially since the repr has changed here already.
The newlines look better to me for multi-dimensional arrays too.
Diffstat (limited to 'numpy/core/arrayprint.py')
| -rw-r--r-- | numpy/core/arrayprint.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index e4be810b9..156a057a3 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -662,16 +662,20 @@ def _formatArray(a, format_function, rank, max_line_len, next_line_prefix, else: s = '[' sep = separator.rstrip() + line_sep = '\n'*max(rank-1, 1) for i in range(leading_items): if i > 0: s += next_line_prefix s += _formatArray(a[i], format_function, rank-1, max_line_len, " " + next_line_prefix, separator, edge_items, summary_insert, legacy) - s = s.rstrip() + sep.rstrip() + '\n'*max(rank-1, 1) + s = s.rstrip() + sep.rstrip() + line_sep if summary_insert1: - s += next_line_prefix + summary_insert1 + "\n" + if legacy == '1.13': + s += next_line_prefix + summary_insert1 + "\n" + else: + s += next_line_prefix + summary_insert1.strip() + line_sep for i in range(trailing_items, 1, -1): if leading_items or i != trailing_items: @@ -679,7 +683,7 @@ def _formatArray(a, format_function, rank, max_line_len, next_line_prefix, s += _formatArray(a[-i], format_function, rank-1, max_line_len, " " + next_line_prefix, separator, edge_items, summary_insert, legacy) - s = s.rstrip() + sep.rstrip() + '\n'*max(rank-1, 1) + s = s.rstrip() + sep.rstrip() + line_sep if leading_items or trailing_items > 1: s += next_line_prefix s += _formatArray(a[-1], format_function, rank-1, max_line_len, |
