Skip to content
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

add repr for empty multidimensional arrays #19862

Merged
merged 1 commit into from Jan 7, 2017

Conversation

stevengj
Copy link
Member

@stevengj stevengj commented Jan 4, 2017

Fixes #19840.

julia> print(Array{Int}(0))
Int64[]
julia> print(Array{Int}(0,0))
Array{Int64}(0,0)
julia> print(Array{Int}(0,5))
Array{Int64}(0,5)

@kshyatt kshyatt added the arrays [a, r, r, a, y, s] label Jan 4, 2017
@ararslan
Copy link
Member

ararslan commented Jan 4, 2017

For consistency with how we print non-empy arrays, should the number of dimensions also be included in the brackets? That is,

julia> print(Array{Int}(0,0))
Array{Int64,2}(0,0)

@stevengj
Copy link
Member Author

stevengj commented Jan 4, 2017

@ararslan, for non-empty arrays print does not display {...} at all.

julia> print(Array{Bool}(2,3,2))
Bool[false true true; false false false]

Bool[false false false; false false false]

@stevengj
Copy link
Member Author

stevengj commented Jan 4, 2017

Note that this patch does not affect the summary header in the multi-line output:

julia> Array{Int}(0,0,0)
0×0×0 Array{Int64,3}

It only affects the show(io, x) output (e.g. for repr, print, etcetera), which otherwise was printing nothing.

@stevengj
Copy link
Member Author

stevengj commented Jan 4, 2017

(Which is not to say we can't print the number of dimensions in the repr, just that there is no need to do so for consistency's sake. I chose not to print it because it was redundant.)

@ararslan
Copy link
Member

ararslan commented Jan 4, 2017

Okay, thanks for the explanation. That makes sense. I guess I was thinking of the summary header in the multiline output, which doesn't correspond directly to this.

@stevengj
Copy link
Member Author

stevengj commented Jan 5, 2017

Should be good to merge; the Travis failure is the unrelated x86 problem we are having nowadays.

@StefanKarpinski StefanKarpinski added this to the 0.6.0 milestone Jan 6, 2017
@JeffBezanson JeffBezanson merged commit ae94034 into JuliaLang:master Jan 7, 2017
@stevengj stevengj deleted the emptymulti branch January 7, 2017 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrays [a, r, r, a, y, s]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants