-
-
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: don't show module prefix in :compact
printing mode
#27925
Conversation
You're aware of #23806, right? I'd tend to think that skipping the module prefix when the type is reachable from the current module is enough. The rule should probably be improved to skip the |
Yep, this is a big deal:
In the Images world we try to print summaries like this: julia> module Mine
using FixedPointNumbers, Colors
function makearray()
rgb8 = rand(RGB{N0f8}, 3, 5)
view(rgb8, 2:3, :)
end
end
julia> Mine.makearray()
2×5 view(::Array{RGB{N0f8},2}, 2:3, :) with eltype ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}}:
RGB{N0f8}(0.553,0.51,0.918) RGB{N0f8}(0.69,0.859,0.031) RGB{N0f8}(0.306,0.82,0.518) RGB{N0f8}(0.655,0.941,0.859) RGB{N0f8}(0.976,0.016,0.184)
RGB{N0f8}(0.267,0.271,0.188) RGB{N0f8}(0.392,0.302,0.878) RGB{N0f8}(0.141,0.533,0.482) RGB{N0f8}(0.878,0.322,0.706) RGB{N0f8}(0.89,0.984,0.322) The main point is that we scope the types with the module name (when the module is not reachable from Main) in one place, after the "with eltype"; everywhere else we use the abbreviated printing. Compare julia> typeof(ans)
SubArray{ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}},2,Array{ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}},2},Tuple{UnitRange{Int64},Base.Slice{Base.OneTo{Int64}}},false} which is much harder to read. And this is nowhere near the full complexity of what one can easily generate in real code; I've frequently seen the type (i.e., without any values) of an AbstractArray take up an entire screen. The use of |
@timholy I'm not sure what you're advocating for. Are you saying |
I disagree; often packages will return objects with types you're not explicitly using, and compact printing should still be compact. The fully qualified element type can still be shown in the header, so you're not really missing information. |
9c3fb6f
to
4cee1e2
Compare
@nalimilan, this is orthogonal to #23806. In my example I deliberately made it so that The main point was that you probably don't want module scoping when printing values, but you might when printing types in summaries. Jeff's edited version is much more along the lines of what I think the behavior should be (in his original summary line I was a bit worried about the module scoping not being present). So now I approve of Jeff's proposal. |
Fine with me. Should we also check |
4cee1e2
to
38e19d0
Compare
What about checking against the |
This isn't type information, it's module qualification. To me |
My view was maybe a bit stretched, but the idea was that if a type must be printed (like |
38e19d0
to
af8f9d3
Compare
Before:
after:
I suspect some packages have added
show
methods just because of this, since it gets quite annoying for big arrays. This doesn't affect 1-d arrays, since they no longer use:compact
, but I'd like to do something about that if possible --- either use compact printing for all array elements, or change it based on the type of each element.