Skip to content
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

Strange display() error with Gadfly #1460

Closed
tomyun opened this issue Jun 26, 2020 · 2 comments
Closed

Strange display() error with Gadfly #1460

tomyun opened this issue Jun 26, 2020 · 2 comments

Comments

@tomyun
Copy link

tomyun commented Jun 26, 2020

Normal behavior before using Gadfly:

julia> collect(())
0-element Array{Union{},1}

After importing Gadfly:

julia> using Gadfly

julia> collect(())
Error showing value of type Array{Union{},1}:
ERROR: MethodError: no method matching display(::Array{Union{},1})
Closest candidates are:
  display(::Any) at multimedia.jl:320
  display(::TextDisplay, ::MIME{Symbol("text/plain")}, ::Any) at multimedia.jl:240
  display(::TextDisplay, ::MIME, ::Any) at multimedia.jl:246
  ...
Stacktrace:
 [1] display(::Any) at ./multimedia.jl:330
 [2] #invokelatest#1 at ./essentials.jl:712 [inlined]
 [3] invokelatest at ./essentials.jl:711 [inlined]
 [4] print_response(::IO, ::Any, ::Bool, ::Bool, ::Any) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:161
 [5] print_response(::REPL.AbstractREPL, ::Any, ::Bool, ::Bool) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:146
 [6] (::REPL.var"#do_respond#38"{Bool,REPL.var"#48#57"{REPL.LineEditREPL,REPL.REPLHistoryProvider},REPL.LineEditREPL,REPL.LineEdit.Prompt})(::Any, ::Any, ::Any) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:729
 [7] (::REPL.var"#53#62")(::Any, ::Any, ::Vararg{Any,N} where N) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:997
 [8] #invokelatest#1 at ./essentials.jl:712 [inlined]
 [9] invokelatest at ./essentials.jl:711 [inlined]
 [10] (::REPL.LineEdit.var"#22#23"{REPL.var"#53#62",String})(::Any, ::Any) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/LineEdit.jl:1364
 [11] prompt!(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/LineEdit.jl:2446
 [12] run_interface(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/LineEdit.jl:2349
 [13] run_frontend(::REPL.LineEditREPL, ::REPL.REPLBackendRef) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:1055
 [14] run_repl(::REPL.AbstractREPL, ::Any) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:206
 [15] (::Base.var"#764#766"{Bool,Bool,Bool,Bool})(::Module) at ./client.jl:383
 [16] #invokelatest#1 at ./essentials.jl:712 [inlined]
 [17] invokelatest at ./essentials.jl:711 [inlined]
 [18] run_main_repl(::Bool, ::Bool, ::Bool, ::Bool, ::Bool) at ./client.jl:367
 [19] exec_options(::Base.JLOptions) at ./client.jl:305
 [20] _start() at ./client.jl:484

Seems like it has something do with GadflyDisplay pushed in Base.Multimedia.displays, but I'm not really familiar with how the display stack work. It's from Gadfly 1.3.0 on Julia 1.4.2.

@Mattriks
Copy link
Member

The error is actually caused by Contour.jl. Contour.jl extends Base.show with 2 new methods for Arrays, which confuses what to do with collect(()). The following example illustrates this:

using Gadfly.Stat.Contour
x = collect(())
dsps = Base.Multimedia.displays
# Note typeof(dsps[1]) == Base.TextDisplay
display(dsps[1], x) 
MethodError: show(::Base.TTY, ::MIME{Symbol("text/plain")}, ::Array{Union{},1}) is ambiguous. Candidates:
  show(io::IO, ::MIME{Symbol("text/plain")}, c2s::Array{TC,1}) where TC<:Curve2 in Contour at C:\Users\mjf\.julia\packages\Contour\zVMve\src\Contour.jl:24
  show(io::IO, ::MIME{Symbol("text/plain")}, cls::Array{CL,1}) where CL<:ContourLevel in Contour at C:\Users\mjf\.julia\packages\Contour\zVMve\src\Contour.jl:33
Possible fix, define
  show(::IO, ::MIME{Symbol("text/plain")}, ::Array{Union{},1})

I suggest opening an issue at Contour.jl.

@Mattriks
Copy link
Member

Moved to JuliaGeometry/Contour.jl#59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants