Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Spaces/DiracSpace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ for TYP in (:DiracSpace,:PointSpace)
spacescompatible(a::$TYP,b::$TYP) = a.points == b.points
canonicalspace(a::$TYP) = a

Base.hash(a::$TYP, h::UInt) = hash(a.points, hash($TYP, h))

union_rule(a::$TYP,b::$TYP) = $TYP(sort(union(a.points,b.points)))

function coefficients(cfs::AbstractVector,fromspace::$TYP,tospace::$TYP)
Expand Down
18 changes: 18 additions & 0 deletions test/SpacesTest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,24 @@ using Test
f = Fun(PointSpace(1:4), ones(4))
@test ApproxFunBase.isconstantfun(f)
end

@testset "hash" begin
DS = ApproxFunBase.DiracSpace
for T in (PointSpace, DS)
a, b = T(1:2), T(1:2)
@test a == b
@test hash(a) == hash(b)
@test isequal(a, b)
@test length(Set([a, b])) == 1
@test Dict(a => 1)[b] == 1
@test Set([T(1:2), T(3:4)]) == Set([T(3:4), T(1:2)])
@test hash(T(1:2)) != hash(T(3:4))
@test T([1, 2]) == T([1.0, 2.0])
@test hash(T([1, 2])) == hash(T([1.0, 2.0]))
end
@test PointSpace(1:2) != DS(1:2)
@test hash(PointSpace(1:2)) != hash(DS(1:2))
end
end

@testset "DiracSpace" begin
Expand Down
Loading