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

AlgebraOfGraphics.density() error message: "LoadError: Tuple field type cannot be Union{}." in Julia 1.10 #472

Closed
rdboyes opened this issue Oct 2, 2023 · 6 comments

Comments

@rdboyes
Copy link

rdboyes commented Oct 2, 2023

Bug description

Tutorial code generates a LoadError: Tuple field type cannot be Union{}.

Steps to reproduce

using PalmerPenguins, DataFrames, AlgebraOfGraphics

penguins = dropmissing(DataFrame(PalmerPenguins.load()))

penguin_bill = data(penguins) * mapping(
    :bill_length_mm => (t -> t / 10) => "bill length (cm)",
    :bill_depth_mm => (t -> t / 10) => "bill depth (cm)",
)

plt = penguin_bill * density(npoints=50) * mapping(col = :species)

axis = (width = 225, height = 225)

draw(plt; axis = axis)

Error reporting

ERROR: LoadError: Tuple field type cannot be Union{}
Stacktrace:
  [1] map(f::Function, d::Dictionaries.Indices{Union{}})
    @ Dictionaries C:\Users\Randy\.julia\packages\Dictionaries\7aBxp\src\map.jl:91
  [2] unnest(vs::Vector{@NamedTuple{}}, indices::Dictionaries.Indices{Union{}})
    @ AlgebraOfGraphics C:\Users\Randy\.julia\packages\AlgebraOfGraphics\yhdjr\src\algebra\layer.jl:81
  [3] unnest_dictionaries(vs::Vector{@NamedTuple{}})
    @ AlgebraOfGraphics C:\Users\Randy\.julia\packages\AlgebraOfGraphics\yhdjr\src\algebra\layer.jl:84
  [4] map(f::AlgebraOfGraphics.var"#192#193"{@NamedTuple{datalimits::Tuple{Tuple{Float64, Float64}, Tuple{Float64, Float64}}, npoints::Int64}}, processedlayer::ProcessedLayer)
    @ AlgebraOfGraphics C:\Users\Randy\.julia\packages\AlgebraOfGraphics\yhdjr\src\algebra\layer.jl:101
  [5] (::AlgebraOfGraphics.DensityAnalysis{MakieCore.Automatic, MakieCore.Automatic, MakieCore.Automatic})(input::ProcessedLayer)
    @ AlgebraOfGraphics C:\Users\Randy\.julia\packages\AlgebraOfGraphics\yhdjr\src\transformations\density.jl:30
  [6] process(layer::Layer)
    @ AlgebraOfGraphics C:\Users\Randy\.julia\packages\AlgebraOfGraphics\yhdjr\src\algebra\processing.jl:102
  [7] iterate
    @ Base .\generator.jl:47 [inlined]
  [8] collect(itr::Base.Generator{Layers, typeof(AlgebraOfGraphics.process)})
    @ Base .\array.jl:832
  [9] map
    @ Base .\abstractarray.jl:3301 [inlined]
 [10] ProcessedLayers(a::Layer)
    @ AlgebraOfGraphics C:\Users\Randy\.julia\packages\AlgebraOfGraphics\yhdjr\src\algebra\layers.jl:41
 [11] compute_axes_grid(d::Layer; axis::@NamedTuple{width::Int64, height::Int64}, palettes::@NamedTuple{})
    @ AlgebraOfGraphics C:\Users\Randy\.julia\packages\AlgebraOfGraphics\yhdjr\src\algebra\layers.jl:114
 [12] compute_axes_grid
    @ AlgebraOfGraphics C:\Users\Randy\.julia\packages\AlgebraOfGraphics\yhdjr\src\algebra\layers.jl:110 [inlined]
 [13] compute_axes_grid(fig::Makie.Figure, d::Layer; axis::@NamedTuple{width::Int64, height::Int64}, palettes::@NamedTuple{})
    @ AlgebraOfGraphics C:\Users\Randy\.julia\packages\AlgebraOfGraphics\yhdjr\src\algebra\layers.jl:100
 [14] compute_axes_grid
    @ AlgebraOfGraphics C:\Users\Randy\.julia\packages\AlgebraOfGraphics\yhdjr\src\algebra\layers.jl:97 [inlined]
 [15] #240
    @ AlgebraOfGraphics C:\Users\Randy\.julia\packages\AlgebraOfGraphics\yhdjr\src\draw.jl:21 [inlined]
 [16] update
    @ AlgebraOfGraphics C:\Users\Randy\.julia\packages\AlgebraOfGraphics\yhdjr\src\draw.jl:10 [inlined]
 [17] plot!(fig::Makie.Figure, d::Layer; axis::@NamedTuple{width::Int64, height::Int64}, palettes::@NamedTuple{})
    @ AlgebraOfGraphics C:\Users\Randy\.julia\packages\AlgebraOfGraphics\yhdjr\src\draw.jl:21
 [18] plot!
    @ AlgebraOfGraphics C:\Users\Randy\.julia\packages\AlgebraOfGraphics\yhdjr\src\draw.jl:16 [inlined]
 [19] (::AlgebraOfGraphics.var"#244#245"{@NamedTuple{width::Int64, height::Int64}, @NamedTuple{}, @NamedTuple{}, @NamedTuple{}, @NamedTuple{}, Layer})(f::Makie.Figure)
    @ AlgebraOfGraphics C:\Users\Randy\.julia\packages\AlgebraOfGraphics\yhdjr\src\draw.jl:48
 [20] update
    @ AlgebraOfGraphics C:\Users\Randy\.julia\packages\AlgebraOfGraphics\yhdjr\src\draw.jl:10 [inlined]
 [21] #draw#243
    @ AlgebraOfGraphics C:\Users\Randy\.julia\packages\AlgebraOfGraphics\yhdjr\src\draw.jl:47 [inlined]
 [22] top-level scope
    @ c:\Users\Randy\.julia\dev\TidierPlots\scratch\density_test.jl:14
in expression starting at c:\Users\Randy\.julia\dev\TidierPlots\scratch\density_test.jl:14

Version info

Julia Version 1.10.0-beta2
Commit a468aa198d (2023-08-17 06:27 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 6 × Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
  Threads: 1 on 6 virtual cores
Environment:
  JULIA_EDITOR = code
  JULIA_NUM_THREADS =
@rdboyes
Copy link
Author

rdboyes commented Oct 10, 2023

I'm thinking this issue is caused by this change to Julia in 1.10:

A new more-specific rule for methods resolves ambiguities containing Union{} in favor of the method defined explicitly to handle the Union{} argument. This makes it possible to define methods to explicitly handle Union{} without the ambiguities that commonly would result previously. This also lets the runtime optimize certain method lookups in a way that significantly improves load and inference times for heavily overloaded methods that dispatch on Types (such as traits and constructors).

Possibly the error is happening here?:

_kde(data::NTuple{1, Any}; kwargs...) = kde(data...; kwargs...)

@sethaxen
Copy link

I'm encountering this too with this simpler reproducer:

julia> draw(
           data((x=randn(100), y=randn(100))) *
           mapping(:x, :y) *
           AlgebraOfGraphics.density() *
           visual(Contour)
       )
ERROR: Tuple field type cannot be Union{}
Stacktrace:
  [1] map(f::Function, d::Dictionaries.Indices{Union{}})
    @ Dictionaries ~/.julia/packages/Dictionaries/7aBxp/src/map.jl:91
  [2] unnest(vs::Vector{@NamedTuple{}}, indices::Dictionaries.Indices{Union{}})
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/tbMEb/src/algebra/layer.jl:81
  [3] unnest_dictionaries(vs::Vector{@NamedTuple{}})
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/tbMEb/src/algebra/layer.jl:84
  [4] map(f::AlgebraOfGraphics.var"#193#194"{@NamedTuple{}}, processedlayer::ProcessedLayer)
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/tbMEb/src/algebra/layer.jl:101
  [5] (::AlgebraOfGraphics.DensityAnalysis{…})(input::ProcessedLayer)
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/tbMEb/src/transformations/density.jl:30
  [6] call_composed
    @ Base ./operators.jl:1045 [inlined]
  [7] call_composed
    @ Base ./operators.jl:1044 [inlined]
  [8] (::ComposedFunction{AlgebraOfGraphics.Visual, AlgebraOfGraphics.DensityAnalysis{…}})(x::ProcessedLayer)
    @ Base ./operators.jl:1041
  [9] process(layer::Layer)
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/tbMEb/src/algebra/processing.jl:102
 [10] iterate(g::Base.Generator, s::Vararg{Any})
    @ Base ./generator.jl:47 [inlined]
 [11] collect(itr::Base.Generator{Layers, typeof(AlgebraOfGraphics.process)})
    @ Base ./array.jl:834
 [12] map
    @ ./abstractarray.jl:3310 [inlined]
 [13] ProcessedLayers(a::Layer)
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/tbMEb/src/algebra/layers.jl:41
 [14] compute_axes_grid(d::Layer; axis::@NamedTuple{}, palettes::@NamedTuple{})
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/tbMEb/src/algebra/layers.jl:114
 [15] compute_axes_grid
    @ ~/.julia/packages/AlgebraOfGraphics/tbMEb/src/algebra/layers.jl:110 [inlined]
 [16] compute_axes_grid(fig::Figure, d::Layer; axis::@NamedTuple{}, palettes::@NamedTuple{})
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/tbMEb/src/algebra/layers.jl:100
 [17] compute_axes_grid
    @ ~/.julia/packages/AlgebraOfGraphics/tbMEb/src/algebra/layers.jl:97 [inlined]
 [18] #241
    @ ~/.julia/packages/AlgebraOfGraphics/tbMEb/src/draw.jl:21 [inlined]
 [19] update
    @ ~/.julia/packages/AlgebraOfGraphics/tbMEb/src/draw.jl:10 [inlined]
 [20] plot!(fig::Figure, d::Layer; axis::@NamedTuple{}, palettes::@NamedTuple{})
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/tbMEb/src/draw.jl:21
 [21] plot!
    @ ~/.julia/packages/AlgebraOfGraphics/tbMEb/src/draw.jl:16 [inlined]
 [22] (::AlgebraOfGraphics.var"#245#246"{})(f::Figure)
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/tbMEb/src/draw.jl:48
 [23] update
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/tbMEb/src/draw.jl:10 [inlined]
 [24] #draw#244
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/tbMEb/src/draw.jl:47 [inlined]
 [25] draw(d::Layer)
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/tbMEb/src/draw.jl:44
 [26] top-level scope
    @ REPL[7]:1
Some type information was truncated. Use `show(err)` to see complete types.

@joshualeond
Copy link

@sethaxen and @rdboyes you see that latest comment that this is likely an issue with the Dictionaries.jl package instead? JuliaLang/julia#52385 (comment)

@rdboyes
Copy link
Author

rdboyes commented Dec 20, 2023

I saw it! I meant to post an issue on Dictionaries but I haven't gotten around to it yet

@palday
Copy link
Contributor

palday commented Dec 28, 2023

I've got a PR to Dictionaries with a fix: andyferris/Dictionaries.jl#127

@lazarusA
Copy link

lazarusA commented Jan 1, 2024

well, this is unfortunate, now AoG is really failing with a lot of my examples :( due to this .

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

5 participants