-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
MAINT: Combine legacy sections of _formatArray #10143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
numpy/core/arrayprint.py
Outdated
@@ -669,28 +669,29 @@ def _formatArray(a, format_function, rank, max_line_len, next_line_prefix, | |||
else: | |||
s = '[' | |||
sep = separator.rstrip() | |||
line_sep = '\n'*max(rank-1, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need, we already know that rank
is not 0
or 1
, and if it's any other value < 1
we have bigger problems.
|
||
for i in range(trailing_items, 1, -1): | ||
if leading_items or i != trailing_items: | ||
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() + line_sep |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already called rstrip
above, so no point doing it again
8a22a98
to
753291c
Compare
Looks good, just needs a rebase. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, quite a bit clearer.
753291c
to
4c28c8f
Compare
Rebased |
Tests now passing |
All right, merging. Nice cleanup! |
This pulls together the changes in #10120, #9815, and #10129 into a more readable fix.
Now it's pretty easy to see the ways in which the legacy behavior was strange.