rafaqz / DimensionalData.jl

Named dimensions and indexing for julia arrays and other data
https://rafaqz.github.io/DimensionalData.jl/stable/
MIT License
281 stars 42 forks source link

Error when showing Coord #427

Closed sethaxen closed 1 year ago

sethaxen commented 1 year ago

In the REPL, if we execute the first example in the Coord docstring, construction of Coord succeeds, but showing the result errors due to a missing show_properties method for CoordLookupArray:

julia> dim = Coord([(1.0,1.0,1.0), (1.0,2.0,2.0), (3.0,4.0,4.0), (1.0,3.0,4.0)], (X(), Y(), Z()));

julia> dim
Coord CoordLookupArray{Tuple{Float64, Float64, Float64}}Error showing value of type Coord{DimensionalData.Dimensions.CoordLookupArray{Tuple{Float64, Float64, Float64}, Vector{Tuple{Float64, Float64, Float64}}, Tuple{X{Colon}, Y{Colon}, Z{Colon}}, DimensionalData.Dimensions.LookupArrays.NoMetadata}}:
ERROR: MethodError: no method matching show_properties(::IOContext{Base.TTY}, ::DimensionalData.Dimensions.CoordLookupArray{Tuple{Float64, Float64, Float64}, Vector{Tuple{Float64, Float64, Float64}}, Tuple{X{Colon}, Y{Colon}, Z{Colon}}, DimensionalData.Dimensions.LookupArrays.NoMetadata})
Closest candidates are:
  show_properties(::IO, ::DimensionalData.Dimensions.LookupArrays.AbstractSampled) at ~/.julia/packages/DimensionalData/K9D4P/src/LookupArrays/show.jl:25
  show_properties(::IO, ::DimensionalData.Dimensions.LookupArrays.AbstractCategorical) at ~/.julia/packages/DimensionalData/K9D4P/src/LookupArrays/show.jl:34
Stacktrace:
  [1] show(io::IOContext{Base.TTY}, mime::MIME{Symbol("text/plain")}, lookup::DimensionalData.Dimensions.CoordLookupArray{Tuple{Float64, Float64, Float64}, Vector{Tuple{Float64, Float64, Float64}}, Tuple{X{Colon}, Y{Colon}, Z{Colon}}, DimensionalData.Dimensions.LookupArrays.NoMetadata})
    @ DimensionalData.Dimensions.LookupArrays ~/.julia/packages/DimensionalData/K9D4P/src/LookupArrays/show.jl:17
  [2] print_dimval(io::IOContext{Base.TTY}, mime::MIME{Symbol("text/plain")}, lookup::DimensionalData.Dimensions.CoordLookupArray{Tuple{Float64, Float64, Float64}, Vector{Tuple{Float64, Float64, Float64}}, Tuple{X{Colon}, Y{Colon}, Z{Colon}}, DimensionalData.Dimensions.LookupArrays.NoMetadata}, nchars::Int64)
    @ DimensionalData.Dimensions ~/.julia/packages/DimensionalData/K9D4P/src/Dimensions/show.jl:98
  [3] print_dimval(io::IOContext{Base.TTY}, mime::MIME{Symbol("text/plain")}, lookup::DimensionalData.Dimensions.CoordLookupArray{Tuple{Float64, Float64, Float64}, Vector{Tuple{Float64, Float64, Float64}}, Tuple{X{Colon}, Y{Colon}, Z{Colon}}, DimensionalData.Dimensions.LookupArrays.NoMetadata})
    @ DimensionalData.Dimensions ~/.julia/packages/DimensionalData/K9D4P/src/Dimensions/show.jl:96
  [4] show(io::IOContext{Base.TTY}, mime::MIME{Symbol("text/plain")}, dim::Coord{DimensionalData.Dimensions.CoordLookupArray{Tuple{Float64, Float64, Float64}, Vector{Tuple{Float64, Float64, Float64}}, Tuple{X{Colon}, Y{Colon}, Z{Colon}}, DimensionalData.Dimensions.LookupArrays.NoMetadata}})
    @ DimensionalData.Dimensions ~/.julia/packages/DimensionalData/K9D4P/src/Dimensions/show.jl:30
  [5] (::REPL.var"#43#44"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::Any)
    @ REPL ~/.julia/juliaup/julia-1.8.2+0.x64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:267
  [6] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL ~/.julia/juliaup/julia-1.8.2+0.x64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:521
  [7] display(d::REPL.REPLDisplay, mime::MIME{Symbol("text/plain")}, x::Any)
    @ REPL ~/.julia/juliaup/julia-1.8.2+0.x64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:260
  [8] display(d::REPL.REPLDisplay, x::Any)
    @ REPL ~/.julia/juliaup/julia-1.8.2+0.x64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:272
  [9] display(x::Any)
    @ Base.Multimedia ./multimedia.jl:328
 [10] #invokelatest#2
    @ ./essentials.jl:729 [inlined]
 [11] invokelatest
    @ ./essentials.jl:726 [inlined]
 [12] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
    @ REPL ~/.julia/juliaup/julia-1.8.2+0.x64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:296
 [13] (::REPL.var"#45#46"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL ~/.julia/juliaup/julia-1.8.2+0.x64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:278
 [14] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL ~/.julia/juliaup/julia-1.8.2+0.x64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:521
 [15] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL ~/.julia/juliaup/julia-1.8.2+0.x64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:276
 [16] (::REPL.var"#do_respond#66"{Bool, Bool, REPL.var"#77#87"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL ~/.julia/juliaup/julia-1.8.2+0.x64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:857
 [17] #invokelatest#2
    @ ./essentials.jl:729 [inlined]
 [18] invokelatest
    @ ./essentials.jl:726 [inlined]
 [19] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit ~/.julia/juliaup/julia-1.8.2+0.x64/share/julia/stdlib/v1.8/REPL/src/LineEdit.jl:2510
 [20] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL ~/.julia/juliaup/julia-1.8.2+0.x64/share/julia/stdlib/v1.8/REPL/src/REPL.jl:1248
 [21] (::REPL.var"#49#54"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL ./task.jl:484

It seems show for Coord was broken by #409.

rafaqz commented 1 year ago

Ahh damn. I don't think we have enough test for Coord, and I don't actually use it and forget about it.