Skip to content

BUG: Fix downcasting in _array2string - #10131

Merged
mhvk merged 1 commit into
numpy:masterfrom
eric-wieser:fix-array2string-asarray
Nov 30, 2017
Merged

mhvk merged 1 commit into
numpy:masterfrom
eric-wieser:fix-array2string-asarray

Conversation

@eric-wieser

@eric-wieser eric-wieser commented Nov 30, 2017 •

Copy link
Copy Markdown
Member

If there are no elements to remove, _leading_trailing returns a subclass view, rather than its normal behaviour of returning an ndarray copy.

Since we call asarray in the other branch of this if anyway, we may as well do it in both.


I wasn't able to construct a test for this. The first step would be to set the threshold much lower than the edge items:

np.set_printoptions(edgeitems=200, threshold=1)

But I can't construct any cases that pass after but fail before.

Split from #10123

If there are no elements to remove, _leading_trailing returns a subclass view, rather than its normal behaviour of returning an ndarray copy.

Since we call `asarray` in the other branch of this `if` anyway, we may as well do it in both.

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since before _leading_trailing made it into an array via the concatenate operation, this seems entirely valid. I also like the comment; since this is trivial, I'll go ahead and merge.

@mhvk
mhvk merged commit 2c31091 into numpy:master Nov 30, 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