-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Redundant type information printed for arrays with Union eltype #26847
Comments
Am I right that we don't have any form of printing that shows |
Also, I don't think redundant type information is a big problem (compared to incorrect output, errors, etc.) |
Actually, this is kind of a bug:
I'm not sure whether that conversion should be defined. |
Yeah, right. I just mentioned that in passing in case that wasn't intended.
That's still a serious issue in some cases. It makes julia> CategoricalArray([1, 2, 3, missing])
4-element CategoricalArray{Union{Missing, Int64},1,UInt32,Int64,CategoricalValue{Int64,UInt32},Missing}:
CategoricalValue{Int64,UInt32} 1
CategoricalValue{Int64,UInt32} 2
CategoricalValue{Int64,UInt32} 3
missing This can also affect the printing of any type with a verbose printing. Of course one can omit type information in all contexts, but that defeats the purpose of the
IIRC I omitted it intentionally since there's an annoying special case for |
Actually I've been able to fix this very easily in CategoricalArrays by adapting the check for |
It doesn't seem like there's anything actionable here? close? |
We can certainly do something about this if we want. The question is whether we want to or not. Here's an simpler example of the verbose printing of julia> Float32[1.0]
1-element Array{Float32,1}:
1.0
julia> Union{Missing,Float32}[1.0]
1-element Array{Union{Missing, Float32},1}:
1.0f0 The useless |
The problem here is elements not taking full advantage of typeinfo in the case when |
The new
typeinfo
IOContext
property (#24651) has no effect for arrays withUnion
element types, since we require the type of elements to be exactly equal to the element type of the array. This is particular annoying forUnion{T,Missing}
arrays, for example with CategoricalArrays. A simple reproducer with only Base types is:The problem may be more complex to fix than it seems, given that in some cases of
Union
element types, type information for each element may still be needed to unambiguously identify each entry. For example, here thef0
suffix adds information:By the way, the following behavior is probably a bug:
So the simplest approach would be to add a special-case for
Missing
andNothing
, or maybe for singleton types in general (assuming they will generally not have the same representation as another type).Cc: @rfourquet
The text was updated successfully, but these errors were encountered: