Repository navigation
Commit b504fca
Define hash for the remaining spaces (#700)
* Define hash for the remaining spaces
PR #698 fixed PointSpace and DiracSpace, but every other space in this
package was in the same position: Space.jl:165 defines == as
spacescompatible plus equal domains, while hash fell back to the
identity-based default. Equal-valued spaces therefore hashed differently
whenever they held a mutable field, or whenever the domains compared equal
without being identical objects:
julia> u1, u2 = UnionDomain([0..1, 2..3]), UnionDomain([2..3, 0..1]);
julia> ConstantSpace(u1) == ConstantSpace(u2)
true
julia> hash(ConstantSpace(u1)) == hash(ConstantSpace(u2))
false
Since == is a conjunction that includes domain(A) == domain(B), hashing the
domain always agrees with ==, and this is all that is needed for the spaces
that only compare domains: ZeroSpace, ConstantSpace, ContinuousSpace and
SplineSpace. The order of a SplineSpace is part of the type, and it is mixed
in so that splines of different orders over the same domain don't collide.
The remaining spaces additionally hash whatever spacescompatible compares:
the components for SumSpace, PiecewiseSpace, ArraySpace and TensorSpace, the
space and the indices for SubSpace, and the underlying space for
QuotientSpace, whose boundary conditions are not compared by == either.
Two direct sums may hold their pieces in different containers and still be
equal, so their components are hashed one at a time instead of hashing the
container. Base hashes a range through its length, which it can't do for the
infinite ranges that SubSpace often uses, so these are hashed through their
first index and step instead.
PiecewiseSegment overrides == to compare points, so it needs a matching hash
as well; ContinuousSpace and SplineSpace hash it as their domain.
Spaces that compare their domains do so with domainscompatible, which uses
isapprox, so == is not transitive for them and no hash function can respect
it exactly. Hashing the domain reproduces == for exactly equal domains,
which is the case that matters for a Dict or a Set.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ay3nR9CQtrrZj3r5LFu59c
* Bump version from 0.9.37 to 0.9.38
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ay3nR9CQtrrZj3r5LFu59c
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent a772275 commit b504fca
12 files changed
Lines changed: 129 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
| 332 | + | |
| 333 | + | |
332 | 334 | | |
333 | 335 | | |
334 | 336 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
624 | 624 | | |
625 | 625 | | |
626 | 626 | | |
| 627 | + | |
| 628 | + | |
627 | 629 | | |
628 | 630 | | |
629 | 631 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| 185 | + | |
185 | 186 | | |
186 | 187 | | |
187 | 188 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
87 | 95 | | |
88 | 96 | | |
89 | 97 | | |
| |||
0 commit comments