Compose.jl
Compose.jl copied to clipboard
`Compose.Table` raises unexpected error on 32-bit Linux
when building the docs for Gadfly.jl using v1.3.1 of the 32-bit Julia binary for Linux, i get the following error:
MethodError: no method matching Compose.Table(::Int32, ::Int64, ::UnitRange{Int32}, ::UnitRange{Int64}; x_prop=[1.0, 1.0, 1.0], y_prop=[1.0], fixed_configs=Any[Tuple{Int32,Int32}[(1, 1)], Tuple{Int32,Int32}[(1, 2)], Tuple{Int32,Int64}[(2, 3), (2, 4), (2, 5)], Tuple{Int32,Int64}[(3, 3), (3, 4), (3, 5)]])
steps to reproduce:
git clone [email protected]:GiovineItalia/Gadfly.jl.git
cd Gadfly.jl
rm -Rf ~/.julia/* # clean local packages
julia -e 'using Pkg; Pkg.add(PackageSpec(name="Compose", rev="master"))'
julia --color=yes --project=docs -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' && julia --color=yes --project=docs docs/make.jl
full stack trace:
ERROR: LoadError: MethodError: no method matching Compose.Table(::Int32, ::Int64, ::UnitRange{Int32}, ::UnitRange{Int64}; x_prop=[1.0, 1.0, 1.0], y_prop=[1.0], fixed_configs=Any[Tuple{Int32,Int32}[(1, 1)], Tuple{Int32,Int32}[(1, 2)], Tuple{Int32,Int64}[(2, 3), (2, 4), (2, 5)], Tuple{Int32,Int64}[(3, 3), (3, 4), (3, 5)]])
Closest candidates are:
Compose.Table(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any) at /home/slowpoke/.julia/packages/Compose/aVZwV/src/table.jl:7 got unsupported keyword arguments "x_prop", "y_prop", "fixed_configs"
Compose.Table(::Integer, ::Integer, ::UnitRange{Int32}, ::UnitRange{Int32}; y_prop, x_prop, aspect_ratio, units, order, withjs, withoutjs, fixed_configs) at /home/slowpoke/.julia/packages/Compose/aVZwV/src/table.jl:46
Compose.Table(::Array{Array{Context,1},2}, ::UnitRange{Int32}, ::UnitRange{Int32}, ::Union{Nothing, Array{Float64,1}}, ::Union{Nothing, Array{Float64,1}}, ::Union{Nothing, Float64}, ::Array{T,1} where T, ::Union{Nothing, UnitBox}, ::Int32, ::Bool, ::Bool) at /home/slowpoke/.julia/packages/Compose/aVZwV/src/table.jl:7 got unsupported keyword arguments "x_prop", "y_prop", "fixed_configs"
Stacktrace:
[1] render(::Gadfly.Geom.SubplotGrid, ::Theme, ::Gadfly.Aesthetics, ::Array{Gadfly.Aesthetics,1}, ::Array{Gadfly.Data,1}, ::Dict{Symbol,Gadfly.ScaleElement}) at /home/slowpoke/sandbox/Gadfly.jl/src/geom/subplot.jl:262
[2] (::Gadfly.var"#108#109"{Dict{Symbol,Gadfly.ScaleElement}})(::Tuple{Layer,Gadfly.Aesthetics,Array{Gadfly.Aesthetics,1},Array{Gadfly.Data,1},Theme}) at ./none:0
[3] collect(::Base.Generator{Base.Iterators.Zip{Tuple{Array{Layer,1},Array{Gadfly.Aesthetics,1},Array{Array{Gadfly.Aesthetics,1},1},Array{Array{Gadfly.Data,1},1},Array{Theme,1}}},Gadfly.var"#108#109"{Dict{Symbol,Gadfly.ScaleElement}}}) at ./generator.jl:47
[4] #render_prepared#107(::Bool, ::Bool, ::typeof(Gadfly.render_prepared), ::Plot, ::Gadfly.Coord.SubplotGrid, ::Gadfly.Aesthetics, ::Array{Gadfly.Aesthetics,1}, ::Array{Array{Gadfly.StatisticElement,1},1}, ::Array{Array{Gadfly.Aesthetics,1},1}, ::Array{Array{Gadfly.Data,1},1}, ::Dict{Symbol,Gadfly.ScaleElement}, ::Array{Gadfly.GuideElement,1}) at /home/slowpoke/sandbox/Gadfly.jl/src/Gadfly.jl:824
[5] render_prepared(::Plot, ::Gadfly.Coord.SubplotGrid, ::Gadfly.Aesthetics, ::Array{Gadfly.Aesthetics,1}, ::Array{Array{Gadfly.StatisticElement,1},1}, ::Array{Array{Gadfly.Aesthetics,1},1}, ::Array{Array{Gadfly.Data,1},1}, ::Dict{Symbol,Gadfly.ScaleElement}, ::Array{Gadfly.GuideElement,1}) at /home/slowpoke/sandbox/Gadfly.jl/src/Gadfly.jl:813
[6] render(::Plot) at /home/slowpoke/sandbox/Gadfly.jl/src/Gadfly.jl:759
[7] draw at /home/slowpoke/sandbox/Gadfly.jl/src/Gadfly.jl:864 [inlined]
[8] show(::Base.GenericIOBuffer{Array{UInt8,1}}, ::MIME{Symbol("text/html")}, ::Plot) at /home/slowpoke/sandbox/Gadfly.jl/src/Gadfly.jl:954
[9] __binrepr at ./multimedia.jl:157 [inlined]
[10] _textrepr at ./multimedia.jl:149 [inlined]
[11] #stringmime#6(::Nothing, ::typeof(Base64.stringmime), ::MIME{Symbol("text/html")}, ::Plot) at /buildworker/worker/package_linux32/build/usr/share/julia/stdlib/v1.3/Base64/src/Base64.jl:43
[12] stringmime(::MIME{Symbol("text/html")}, ::Plot) at /buildworker/worker/package_linux32/build/usr/share/julia/stdlib/v1.3/Base64/src/Base64.jl:43
[13] display_dict(::Plot) at /home/slowpoke/.julia/packages/Documenter/Eayks/src/Utilities/Utilities.jl:652
[14] #invokelatest#1 at ./essentials.jl:709 [inlined]
[15] invokelatest at ./essentials.jl:708 [inlined]
[16] runner(::Type{Documenter.Expanders.ExampleBlocks}, ::Markdown.Code, ::Documenter.Documents.Page, ::Documenter.Documents.Document) at /home/slowpoke/.julia/packages/Documenter/Eayks/src/Expanders.jl:571
[17] dispatch(::Type{Documenter.Expanders.ExpanderPipeline}, ::Markdown.Code, ::Vararg{Any,N} where N) at /home/slowpoke/.julia/packages/Documenter/Eayks/src/Utilities/Selectors.jl:167
[18] expand(::Documenter.Documents.Document) at /home/slowpoke/.julia/packages/Documenter/Eayks/src/Expanders.jl:30
[19] runner(::Type{Documenter.Builder.ExpandTemplates}, ::Documenter.Documents.Document) at /home/slowpoke/.julia/packages/Documenter/Eayks/src/Builder.jl:179
[20] dispatch(::Type{Documenter.Builder.DocumentPipeline}, ::Documenter.Documents.Document) at /home/slowpoke/.julia/packages/Documenter/Eayks/src/Utilities/Selectors.jl:167
[21] #3 at /home/slowpoke/.julia/packages/Documenter/Eayks/src/Documenter.jl:287 [inlined]
[22] cd(::Documenter.var"#3#8"{Documenter.Documents.Document}, ::String) at ./file.jl:104
[23] #makedocs#1(::Bool, ::Documenter.Writers.HTMLWriter.HTML, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Base.Iterators.Pairs{Symbol,Any,NTuple{4,Symbol},NamedTuple{(:modules, :clean, :sitename, :pages),Tuple{Array{Module,1},Bool,String,Array{Any,1}}}}, ::typeof(makedocs)) at /home/slowpoke/.julia/packages/Documenter/Eayks/src/Documenter.jl:286
[24] (::Documenter.var"#kw##makedocs")(::NamedTuple{(:modules, :clean, :sitename, :pages),Tuple{Array{Module,1},Bool,String,Array{Any,1}}}, ::typeof(makedocs)) at ./none:0
[25] top-level scope at /home/slowpoke/sandbox/Gadfly.jl/docs/make.jl:3
[26] include at ./boot.jl:328 [inlined]
[27] include_relative(::Module, ::String) at ./loading.jl:1105
[28] include(::Module, ::String) at ./Base.jl:31
[29] exec_options(::Base.JLOptions) at ./client.jl:287
[30] _start() at ./cliendt.jl:460
in expression starting at /home/slowpoke/sandbox/Gadfly.jl/docs/make.jl:3
(originally referenced in: https://github.com/GiovineItalia/Gadfly.jl/issues/1374#issuecomment-576054508)
Perhaps the possible fixes are in three layers.
- User input (i.e. script in "docs")
- Gadfly.jl (i.e. callers of
Table
) - Compose.jl (e.g.
Table(m::Integer, n::Integer, y_focus::UnitRange{<:Integer}, x_focus::UnitRange{<:Integer}; ...
)
Considering the compatibility with (earlier) Compose.jl, it seems better to take 1. or 2. first.
Here's a simple "Compose-only" example on a 64-bit system:
x_focus = UnitRange{Int32}(1:3)
y_focus = UnitRange{Int32}(1:1)
Compose.Table(3,1, x_focus, y_focus, x_prop=ones(Float32,3), y_prop=ones(Float32,1))
MethodError: no method matching Compose.Table(::Int64, ::Int64, ::UnitRange{Int32}, ::UnitRange{Int32}; x_prop=Float32[1.0, 1.0, 1.0], y_prop=Float32[1.0])
I'd say this is a bug that's been introduced when upgrading Compose, so point 3 above is the solution for Compose.
FWIW, "git blame" says this is a potential issue from the beginning. Of course, I think modifying Compose.jl is fine.
Wondering what the root cause is here in the 32-bit Gadfly example above. E.g. is Gadfly or one of it's dependencies mistakenly forcing Int64
(giving rise to UnitRange{Int64}
) when it should be using Int
. The suspect UnitRange "values" originate in this line, so e.g. what is the Integer type of a length of an empty or non-empty DefaultDict
?
This is a topic of Gadfly, not Compose, but I guess DefaultDict
is innocent.
I think the problematic call of table
is here:
https://github.com/GiovineItalia/Gadfly.jl/blob/aec6dad99a4780fb61e409c5b5a591b66c4b728b/src/geom/subplot.jl#L252-L269
I think this line in Gadfly is the issue, because that's where the xgroup
field in the aes
struct gets created. That seems more of a bug than ::UnitRange{Int}
in Compose.
Your point seems to be correct.:+1:
However, it seems to have been changed to Int64
for some intent. I don't know the intent, though.
https://github.com/GiovineItalia/Gadfly.jl/pull/1129
https://github.com/GiovineItalia/Gadfly.jl/pull/1129/commits/1bfe85629cb0724b9d1428f67afd01a4c688a829
@andreasnoack your change of Int
to Int64
(see comment above) breaks Gadfly on 32-bit systems. can you explain why this was needed?
Unfortunately, I don't remember why I made that change and I agree that it looks wrong to use Int64
instead of Int
.
The index of a IndirectArray
should always be an integer:
data = Gadfly.Data(shape=["A","A", "B", "C","C"])
scale = Scale.shape_discrete()
disc_data = Scale.discretize(getfield(data, :shape), scale.levels, scale.order)
disc_data.index # are integers
Can test to see if removing the Int() here causes any errors in Gadfly.
The problem line above got changed in GiovineItalia/Gadfly.jl#1411, so I assume the OP is fixed.
@ben-schulz can you test if this now works on master?