SciML / SciML/LabelledArrays.jl
Display error if struct contains LabelledArray with mixed types
Open
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 125
- Forks
- 20
- Avg merge
- 6h 3m
- Merged PRs (30d)
- 10
Description
Struct does not get displayed if it contains a labelled array with mixed types.
julia> using LabelledArrays
julia> T = @SLVector (:x,:y,:z)
SLArray{Tuple{3},1,(:x, :y, :z),T} where T
julia> T(1,2,3.4)
3-element SLArray{Tuple{3},1,(:x, :y, :z),Real}:
1
2
3.4
julia> [typeof(x) for x in T(1,2,3.4)]
3-element StaticArrays.SizedArray{Tuple{3},DataType,1,1}:
Int64
Int64
Float64
julia> struct H
var :: T
end
julia> a=H(T(1,2,3.4))
H(Error showing value of type H:
ERROR: MethodError: Cannot `convert` an object of type LabelledArrays.DisplayCell{Int64} to an object of type LabelledArrays.DisplayCell{Real}
Closest candidates are:
convert(::Type{T}, ::T) where T at essentials.jl:154
LabelledArrays.DisplayCell{Real}(::Any, ::Any) where T at /home/user/.julia/packages/LabelledArrays/Y2gSe/src/display.jl:2
Stacktrace:
[1] setindex!(::Array{LabelledArrays.DisplayCell{Real},1}, ::LabelledArrays.DisplayCell{Int64}, ::Int64) at ./array.jl:767
[2] show(::IOContext{REPL.Terminals.TTYTerminal}, ::SLArray{Tuple{3},1,(:x, :y, :z),Real}) at /home/user/.julia/packages/LabelledArrays/Y2gSe/src/display.jl:22
[3] show_default(::IOContext{REPL.Terminals.TTYTerminal}, ::Any) at ./show.jl:332
[4] show at ./show.jl:315 [inlined]
[5] show(::IOContext{REPL.Terminals.TTYTerminal}, ::MIME{Symbol("text/plain")}, ::H) at ./sysimg.jl:194
[6] display(::REPL.REPLDisplay, ::MIME{Symbol("text/plain")}, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:131
[7] display(::REPL.REPLDisplay, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:135
[8] display(::Any) at ./multimedia.jl:287
[9] #invokelatest#1 at ./essentials.jl:742 [inlined]
[10] invokelatest at ./essentials.jl:741 [inlined]
[11] print_response(::IO, ::Any, ::Any, ::Bool, ::Bool, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:155
[12] print_response(::REPL.AbstractREPL, ::Any, ::Any, ::Bool, ::Bool) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:140
[13] (::getfield(REPL, Symbol("#do_respond#38")){Bool,getfield(REPL, Symbol("##48#57")){REPL.LineEditREPL,REPL.REPLHistoryProvider},REPL.LineEditREPL,REPL.LineEdit.Prompt})(::Any, ::Any, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:714
[14] #invokelatest#1 at ./essentials.jl:742 [inlined]
[15] invokelatest at ./essentials.jl:741 [inlined]
[16] run_interface(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/REPL/src/LineEdit.jl:2273
[17] run_frontend(::REPL.LineEditREPL, ::REPL.REPLBackendRef) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:1035
[18] run_repl(::REPL.AbstractREPL, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:192
[19] (::getfield(Base, Symbol("##734#736")){Bool,Bool,Bool,Bool})(::Module) at ./client.jl:362
[20] #invokelatest#1 at ./essentials.jl:742 [inlined]
[21] invokelatest at ./essentials.jl:741 [inlined]
[22] run_main_repl(::Bool, ::Bool, ::Bool, ::Bool, ::Bool) at ./client.jl:346
[23] exec_options(::Base.JLOptions) at ./client.jl:284
[24] _start() at ./client.jl:436
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the example with a struct containing a mixed-type labelled array, then inspect display.jl, especially the constructors near line 2 and show method near line 22. The work is done when displaying the struct no longer raises the DisplayCell conversion error and the mixed values are shown correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100