Skip to content

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

Merged
merged 2 commits into from
Dec 1, 2017

Conversation

eric-wieser
Copy link
Member

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.

@@ -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)
Copy link
Member Author

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
Copy link
Member Author

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

@eric-wieser eric-wieser force-pushed the combine-formatArray-legacy branch 2 times, most recently from 8a22a98 to 753291c Compare December 1, 2017 05:26
@ahaldane
Copy link
Member

ahaldane commented Dec 1, 2017

Looks good, just needs a rebase.

Copy link
Contributor

@mhvk mhvk left a 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.

@eric-wieser eric-wieser force-pushed the combine-formatArray-legacy branch from 753291c to 4c28c8f Compare December 1, 2017 16:50
@eric-wieser
Copy link
Member Author

Rebased

@eric-wieser
Copy link
Member Author

Tests now passing

@ahaldane
Copy link
Member

ahaldane commented Dec 1, 2017

All right, merging. Nice cleanup!

@ahaldane ahaldane merged commit 058abc1 into numpy:master Dec 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants