-
Notifications
You must be signed in to change notification settings - Fork 19
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
unexpected behavior with Set? #142
Comments
Does Set use |
So, I think it has something to do with how set implements push!, and the way string literals work? (not entirely sure) Here's the implementation in Julia: And when I try this at the command line:
Since the string literal expands to a new constructor, and the dictionary is keyed by hashes, the Set always adds a new key,val pair, never overwritting the old? |
Would implementing a custom hash function for Maybe using: https://github.com/JuliaServices/AutoHashEquals.jl |
Yes a custom hash sounds like it would be enough! I’m honesty surprised it doesn’t work automatically based on the fields |
from this thread, it sounds like maybe the default is to hash the type too, producing a new value each time, and if we omitted the type from the hash, that might do it. could be tricky though, since the e.g. the following doesn't work, because (I think), the recursive call to hash(q.dimensions) hashes the dimension type, etc.
|
Okay, I think I figured it out. Thanks for bearing with me here. I'm trying to hash a SymbolicDimensions type, and since it's got a mutable vector field, perhaps it's not possible to produce a consistent hash? I guess I could convert to a Dimensions type first:
|
I think hash can work on Dimensions, but it just needs to have special behavior for SymbolicDimensions that treats the sparsity of those vectors correctly, ignoring any zeros. Then it will work. |
Hi All,
Thanks for the great package!
I'm not sure if this behavior is expected, but it surprised me, so I thought I'd ask.
I would have expected the set to only to have 1 element, because:
Am I mistaken in my intuition here?
Thanks for your time and work.
Cheers,
Max
The text was updated successfully, but these errors were encountered: