Skip to content

WIP: correct maximum element space calculation in array2string#9144

Closed
mhvk wants to merge 1 commit intonumpy:masterfrom
mhvk:arrayprint-fewer-spaces
Closed

WIP: correct maximum element space calculation in array2string#9144
mhvk wants to merge 1 commit intonumpy:masterfrom
mhvk:arrayprint-fewer-spaces

Conversation

@mhvk
Copy link
Copy Markdown
Contributor

@mhvk mhvk commented May 19, 2017

Use less space when all floats are positive, or all booleans are True. With this PR:

np.array(True)
# array(True, dtype=bool)
np.array(1.)
# array(1.)
np.arange(9.).reshape(3,3)
# array([[0., 1., 2.],
#        [3., 4., 5.],
#        [6., 7., 8.]])
np.arange(-2., 7.).reshape(3, 3)
# array([[-2., -1.,  0.],
#        [ 1.,  2.,  3.],
#        [ 4.,  5.,  6.]])

For comparison, in both master and in this PR, for integers:

array([[0, 1, 2],
       [3, 4, 5],
       [6, 7, 8]])
array([[-2, -1,  0],
       [ 1,  2,  3],
       [ 4,  5,  6]])

So, this PR makes the code more consistent (which of course is not necessarily better)

EDIT: I did not adjust any tests (quite a few fail).

Use less space when all floats are positive, or all booleans are True.
@mhvk
Copy link
Copy Markdown
Contributor Author

mhvk commented May 19, 2017

Duh, I just did @ahaldane's #9139 -- closing this even though it is slightly different.

@mhvk mhvk closed this May 19, 2017
@mhvk mhvk deleted the arrayprint-fewer-spaces branch August 31, 2017 23:50
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.

1 participant