Skip to content

BUG: linewidth was not respected for arrays other than 1d - #10175

Merged
ahaldane merged 1 commit into
numpy:masterfrom
eric-wieser:respect-line-width
Dec 8, 2017
Merged

ahaldane merged 1 commit into
numpy:masterfrom
eric-wieser:respect-line-width

Conversation

@eric-wieser

Copy link
Copy Markdown
Member

The available width needs to reduce by one for each dimension, to account for the trailing ] characters

Fixes gh-10170

The available width needs to reduce by one for each dimension, to account for the trailing ] characters

Fixes numpygh-10170
@eric-wieser eric-wieser added this to the 1.14.0 release milestone Dec 8, 2017
Comment thread numpy/core/arrayprint.py

for i in range(trailing_items, 1, -1):
word = recurser(index + (-i,), next_hanging_indent)
word = recurser(index + (-i,), next_hanging_indent, next_width)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not strictly needed here, but in future this could be passed to the format function for printing, say, line-wrapped strings, or nested ndarrays.

Comment thread numpy/core/arrayprint.py

s += hanging_indent + recurser(index + (-1,), next_hanging_indent)
nested = recurser(index + (-1,), next_hanging_indent, next_width)
s += hanging_indent + nested

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines were getting long...

assert_equal(make_str(a, 7), '[11111\n'
' 1]')
assert_equal(make_str(a, 5), '[111\n'
' 111]')

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all extra tests from #10172

@ahaldane

ahaldane commented Dec 8, 2017

Copy link
Copy Markdown
Member

LGTM

@ahaldane

ahaldane commented Dec 8, 2017

Copy link
Copy Markdown
Member

All right, I'm going to merge, Thanks Eric!

@ahaldane
ahaldane merged commit 99015fa into numpy:master Dec 8, 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.

2 participants