-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[RFC/WIP] Handle :compact context in 3-arg show for arrays #34733
Conversation
base/arrayshow.jl
Outdated
# 0) show summary before setting :compact | ||
summary(io, X) | ||
isempty(X) && return | ||
print(io, ":") | ||
show_circular(io, X) && return | ||
|
||
# 1) compute new IOContext | ||
if !haskey(io, :compact) && length(axes(X, 2)) > 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if people are happy with removing length(axes(X, 2)) > 1
.
(BTW I think this is a shortcoming of the way :compact
is used. It's not possible to declare compactness of the width and height separately. This is why I've been suggesting to use :displaysize
instead of :compact
#33260 (comment))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a separate issue and will probably be controversial, so I wouldn't change this for now.
@@ -320,14 +320,21 @@ print_array(io::IO, X::AbstractArray) = show_nd(io, X, print_matrix, true) | |||
# typeinfo aware | |||
# implements: show(io::IO, ::MIME"text/plain", X::AbstractArray) | |||
function show(io::IO, ::MIME"text/plain", X::AbstractArray) | |||
# -1) handle arrays-in-array (recursive call) | |||
if get(io, :compact, false) === true | |||
# Using `show` of method with the most abstract type to avoid infinite recursion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really necessary? I don't think it's common for 2-arg show methods to call 3-arg ones.
@JeffBezanson Note that both changes are required if you want to fix the bug #34659 this way. The problem is that 3-arg Lines 105 to 111 in b0d1c1a
That is to say, since 3-arg show of the inner array Of course, there may be another solution for fixing #34659. Please close this PR if there is a better way. |
You're right; it would only fix this case:
but I think that's worth doing. |
This reverts commit af3fe83.
OK, I put |
Edit: now this PR fixes only
permutedims([Int[], Int[]])
case #34733 (comment)Before:After:
I'm sending this as a WIPI was meant to send this as a WIP PR before fixing the tests as I don't know if the core devs think this is the way to go.fix (a related bug of) #34659