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

Error thrown when pushing a DenseAxisArray into a set #2696

Closed
raphaelsaavedra opened this issue Sep 20, 2021 · 5 comments · Fixed by #2707
Closed

Error thrown when pushing a DenseAxisArray into a set #2696

raphaelsaavedra opened this issue Sep 20, 2021 · 5 comments · Fixed by #2707

Comments

@raphaelsaavedra
Copy link
Contributor

MWE:

julia> d = DenseAxisArray(randn(2,2), rand(2), rand(2))
2-dimensional DenseAxisArray{Float64,2,...} with index sets:
    Dimension 1, [0.5738959292254728, 0.4794514555447127]
    Dimension 2, [0.8252231962521452, 0.09789140248995065]
And data, a 2×2 Matrix{Float64}:
  1.25573  1.43504
 -1.22614  1.25292

julia> s = Set()
Set{Any}()

julia> push!(s, d)
ERROR: ArgumentError: invalid index: JuMP.Containers.DenseAxisArrayKey{Tuple{Float64, Float64}}((0.4794514555447127, 0.09789140248995065)) of type JuMP.Containers.DenseAxisArrayKey{Tuple{Float64, Float64}}
@odow odow added the Type: Bug label Sep 20, 2021
@odow
Copy link
Member

odow commented Sep 20, 2021

Here's the full trace

julia> push!(s, d)
ERROR: ArgumentError: invalid index: JuMP.Containers.DenseAxisArrayKey{Tuple{Float64, Float64}}((0.5794783332719144, 0.5367626173056417)) of type JuMP.Containers.DenseAxisArrayKey{Tuple{Float64, Float64}}
Stacktrace:
  [1] to_index(i::JuMP.Containers.DenseAxisArrayKey{Tuple{Float64, Float64}})
    @ Base ./indices.jl:300
  [2] to_index(A::LinearIndices{2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, i::JuMP.Containers.DenseAxisArrayKey{Tuple{Float64, Float64}})
    @ Base ./indices.jl:277
  [3] to_indices
    @ ./indices.jl:333 [inlined]
  [4] to_indices
    @ ./indices.jl:325 [inlined]
  [5] getindex
    @ ./abstractarray.jl:1170 [inlined]
  [6] hash(A::DenseAxisArray{Float64, 2, Tuple{Vector{Float64}, Vector{Float64}}, Tuple{JuMP.Containers._AxisLookup{Dict{Float64, Int64}}, JuMP.Containers._AxisLookup{Dict{Float64, Int64}}}}, h::UInt64)
    @ Base ./abstractarray.jl:2425
  [7] hash
    @ ./hashing.jl:18 [inlined]
  [8] hashindex
    @ ./dict.jl:169 [inlined]
  [9] ht_keyindex2!(h::Dict{Any, Nothing}, key::DenseAxisArray{Float64, 2, Tuple{Vector{Float64}, Vector{Float64}}, Tuple{JuMP.Containers._AxisLookup{Dict{Float64, Int64}}, JuMP.Containers._AxisLookup{Dict{Float64, Int64}}}})
    @ Base ./dict.jl:310
 [10] setindex!(h::Dict{Any, Nothing}, v0::Nothing, key::DenseAxisArray{Float64, 2, Tuple{Vector{Float64}, Vector{Float64}}, Tuple{JuMP.Containers._AxisLookup{Dict{Float64, Int64}}, JuMP.Containers._AxisLookup{Dict{Float64, Int64}}}})
    @ Base ./dict.jl:383
 [11] push!(s::Set{Any}, x::DenseAxisArray{Float64, 2, Tuple{Vector{Float64}, Vector{Float64}}, Tuple{JuMP.Containers._AxisLookup{Dict{Float64, Int64}}, JuMP.Containers._AxisLookup{Dict{Float64, Int64}}}})
    @ Base ./set.jl:57
 [12] top-level scope
    @ REPL[28]:1

@odow
Copy link
Member

odow commented Sep 20, 2021

I guess we're missing a hash. Should be fixable

@raphaelsaavedra
Copy link
Contributor Author

Thanks a lot @odow! Is it possible to tag a new release with the fix? Or are you guys waiting a bit to release 0.22?

@odow
Copy link
Member

odow commented Sep 25, 2021

We're going to wait a while before releasing 0.22.

For the mean time, it's safe to pirate the hash definitions here: https://github.com/jump-dev/JuMP.jl/pull/2707/files

@raphaelsaavedra
Copy link
Contributor Author

No worries, thanks for the help :)

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

Successfully merging a pull request may close this issue.

2 participants