Skip to content

WIP: correct maximum element space calculation in array2string #9144

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

Closed
wants to merge 1 commit into from

Conversation

mhvk
Copy link
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
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