Fixup hash(::Real) broken by #49996#50067
Conversation
|
Please use meaningful titles for commits and PRs and not #'s |
test/hashing.jl
Outdated
| @test Type{Base.Broadcast.Broadcasted}.hash != 0 | ||
|
|
||
| # Issue #50065 | ||
| @test hash(1.0) == hash(BigFloat(1.0)) |
There was a problem hiding this comment.
add 1//1 and big(1) for good measure.
There was a problem hiding this comment.
I think it makes sense to add BigFloat and BigInt to the massive cross-product at the top instead.
There was a problem hiding this comment.
well I'm sure glad I suggested testing BigInt :)
|
My justification for changing the collisions bound and comment describing it is that the comment is misleading. julia> collides = [];
julia> for T = types, S = types, x = vals
a = coerce(T, x)
b = coerce(S, x)
eq = hash(a) == hash(b)
#println("$(typeof(a)) $a")
#println("$(typeof(b)) $b")
if isequal(a, b)
@test eq
elseif eq
push!(collides, (a,b))
end
end
# each pair of types has one collision for these values
julia> using StatsBase; countmap(typeof.(collides))
Dict{DataType, Int64} with 40 entries:
Tuple{UInt64, Int8} => 2
Tuple{UInt64, Rational{Int16}} => 2
Tuple{Rational{Int8}, Rational{UInt64}} => 2
Tuple{Float32, Rational{UInt64}} => 9
Tuple{Float64, Rational{UInt64}} => 14
⋮ => ⋮On average, each pair of types has 0.947 collisions. Adding BigFloat and BigInt increases this average to 1.076. The new bound is exactly the number of current collisions. |
|
New tests on this PR unearthed a hashing bug for |
… on 32-bit systems.
|
Sounds good. #50076 should fix that part of this. |
|
Test failure looks unrelated |
I mishandled nonzero
powreturned bydecompose(::BigFloat).Fixes #50065 and adds a test