Skip to content

Commit

Permalink
Try to make doctests deterministic
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Aug 30, 2024
1 parent 5919c76 commit 3640a14
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 3 additions & 3 deletions experimental/LieAlgebras/src/LieAlgebraModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1530,14 +1530,14 @@ julia> L = lie_algebra(QQ, :A, 3);
julia> character(L, [2, 0, 0])
Dict{Vector{Int64}, Int64} with 10 entries:
[0, -2, 2] => 1
[0, 1, 0] => 1
[0, -2, 2] => 1
[0, 0, -2] => 1
[-2, 2, 0] => 1
[-1, 1, -1] => 1
[-2, 2, 0] => 1
[1, -1, 1] => 1
[1, 0, -1] => 1
[-1, 0, 1] => 1
[1, 0, -1] => 1
[2, 0, 0] => 1
[0, -1, 0] => 1
```
Expand Down
12 changes: 10 additions & 2 deletions experimental/LieAlgebras/src/RootSystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ function fundamental_weights(R::RootSystem)
return [fundamental_weight(R, i) for i in 1:rank(R)]
end

function Base.hash(R::RootSystem, h::UInt)
# even though we don't have a == method for RootSystem, we add a hash method
# to make hashing of RootSpaceElem and WeightLatticeElem more deterministic
b = 0xeb5362118dea2a0e % UInt
h = hash(cartan_matrix(R), h)
return xor(b, h)
end

function is_simple(R::RootSystem)
if is_finite(weyl_group(R))
return length(root_system_type(R)) == 1
Expand Down Expand Up @@ -1040,8 +1048,8 @@ julia> dominant_weights(Vector{Int}, R, [3, 0, 1])
7-element Vector{Vector{Int64}}:
[3, 0, 1]
[1, 1, 1]
[0, 0, 3]
[2, 0, 1]
[0, 0, 3]
[0, 1, 1]
[1, 0, 1]
[0, 0, 1]
Expand Down Expand Up @@ -1263,8 +1271,8 @@ julia> tensor_product_decomposition(R, [1, 1], [1, 1])
MSet{Vector{Int64}} with 10 elements:
[0, 0]
[0, 4]
[2, 0]
[0, 2] : 2
[2, 0]
[1, 0]
[2, 2]
[3, 0]
Expand Down

0 comments on commit 3640a14

Please sign in to comment.