Skip to content

Commit

Permalink
add tests for canon_inds and canon_inds_remember
Browse files Browse the repository at this point in the history
  • Loading branch information
jfeist committed Sep 17, 2023
1 parent 43e68cb commit e19bbd0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,24 @@ end
@test Pr"α_i_1,μ_2" == Pr"α_{i_1,μ_2}" == param(,'r',:i_1,:μ_2)
@test Pr"α_◔,◔" == Pr"α_{◔,◔}" == param(,'r',:◔,:◔)

@testset "index_functions" begin
x = QuantumAlgebra.canon_inds_remember()
if auto_norm
@test QuantumAlgebra.canon_inds()(f(5)*f(2)*a(9,:k,:m) + a(10)) == -f(:i)*f(:j)*a(:k,:l,:m) + a(:i)
else
@test QuantumAlgebra.canon_inds()(f(5)*f(2)*a(9,:k,:m) + a(10)) == f(:i)*f(:j)*a(:k,:l,:m) + a(:i)
end
t1, _ = only((f(5)*f(2)*a(9,:k,:m)).terms)
t2, _ = only((f(:i)*f(:j)*a(:k,:l,:m)).terms)
indf = QuantumAlgebra.canon_inds_remember()
@test indf(t1) == t2
@test indf.replacements == Dict(QuIndex(:i) => auto_norm ? QuIndex(2) : QuIndex(5),
QuIndex(:j) => auto_norm ? QuIndex(5) : QuIndex(2),
QuIndex(:k) => QuIndex(9), QuIndex(:l) => QuIndex(:k),
QuIndex(:m) => QuIndex(:m))
@test_throws ErrorException indf(a())
end

@testset "normal_form with sums" begin
# bug report from FJ Matute
t1 = Pc"a_w"*Pc"B_x"*Pc"C_y"*Pc"D_z"*f(:w)*f(:x)'*f(:y)*f(:z)'
Expand Down

0 comments on commit e19bbd0

Please sign in to comment.