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

Patterns are not hashable #4878

Open
jkrumbiegel opened this issue Mar 19, 2025 · 2 comments
Open

Patterns are not hashable #4878

jkrumbiegel opened this issue Mar 19, 2025 · 2 comments
Labels

Comments

@jkrumbiegel
Copy link
Member

Because of the AbstractMatrix supertype, an overload kicks in that tries to call getindex which we don't define.

julia> Set([Pattern('/')])
ERROR: CanonicalIndexError: getindex not defined for Makie.LinePattern
Stacktrace:
  [1] error_if_canonical_getindex(::IndexCartesian, ::Makie.LinePattern, ::Int64, ::Int64)
    @ Base ./abstractarray.jl:1327
  [2] getindex
    @ ./abstractarray.jl:1311 [inlined]
  [3] _getindex
    @ ./abstractarray.jl:1358 [inlined]
  [4] getindex
    @ ./abstractarray.jl:1312 [inlined]
  [5] iterate
    @ ./abstractarray.jl:1209 [inlined]
  [6] iterate
    @ ./abstractarray.jl:1207 [inlined]
  [7] hash
    @ ./abstractarray.jl:3549 [inlined]
  [8] hash
    @ ./hashing.jl:28 [inlined]
  [9] hashindex
    @ ./dict.jl:128 [inlined]
 [10] ht_keyindex2_shorthash!(h::Dict{Makie.LinePattern, Nothing}, key::Makie.LinePattern)
    @ Base ./dict.jl:274
 [11] setindex!(h::Dict{Makie.LinePattern, Nothing}, v0::Nothing, key::Makie.LinePattern)
    @ Base ./dict.jl:356
 [12] push!
    @ ./set.jl:137 [inlined]
 [13] union!(s::Set{Makie.LinePattern}, itr::Vector{Makie.LinePattern})
    @ Base ./abstractset.jl:106
 [14] Set
    @ ./set.jl:47 [inlined]
 [15] _Set
    @ ./set.jl:59 [inlined]
 [16] Set(itr::Vector{Makie.LinePattern})
    @ Base ./set.jl:58
 [17] top-level scope
    @ REPL[15]:1
@ffreyer
Copy link
Collaborator

ffreyer commented Mar 19, 2025

I don't think there is a strong reason to have it inherit from AbstractMatrix. I think that's just there because Patterns are more or less an image.

In what context are we using hashing again? Was is it for svg/pdf saving in CairoMakie?

@jkrumbiegel
Copy link
Member Author

It came up for me in AlgebraOfGraphics where a set of attributes can be computed to check for duplicates

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

No branches or pull requests

2 participants