Add tests for AB->ABBB execution and fix errors
This commit is contained in:
@ -7,7 +7,7 @@ using QEDbase
|
||||
include("../examples/profiling_utilities.jl")
|
||||
|
||||
@testset "Unit Tests Execution" begin
|
||||
particles = Tuple{Vector{Particle}, Vector{Particle}}((
|
||||
particles_2_2 = Tuple{Vector{Particle}, Vector{Particle}}((
|
||||
[
|
||||
Particle(SFourMomentum(0.823648, 0.0, 0.0, 0.823648), A),
|
||||
Particle(SFourMomentum(0.823648, 0.0, 0.0, -0.823648), B),
|
||||
@ -27,14 +27,14 @@ include("../examples/profiling_utilities.jl")
|
||||
for _ in 1:10 # test in a loop because graph layout should not change the result
|
||||
graph = parse_abc(joinpath(@__DIR__, "..", "input", "AB->AB.txt"))
|
||||
@test isapprox(
|
||||
execute(graph, particles),
|
||||
execute(graph, particles_2_2),
|
||||
expected_result;
|
||||
rtol = 0.001,
|
||||
)
|
||||
|
||||
code = MetagraphOptimization.gen_code(graph)
|
||||
@test isapprox(
|
||||
execute(code, particles),
|
||||
execute(code, particles_2_2),
|
||||
expected_result;
|
||||
rtol = 0.001,
|
||||
)
|
||||
@ -45,13 +45,51 @@ include("../examples/profiling_utilities.jl")
|
||||
for i in 1:100
|
||||
graph = parse_abc(joinpath(@__DIR__, "..", "input", "AB->AB.txt"))
|
||||
random_walk!(graph, 50)
|
||||
@test is_valid(graph)
|
||||
|
||||
@test isapprox(
|
||||
execute(graph, particles),
|
||||
execute(graph, particles_2_2),
|
||||
expected_result;
|
||||
rtol = 0.001,
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
particles_2_4 = gen_particles([A, B], [A, B, B, B])
|
||||
graph = parse_abc(joinpath(@__DIR__, "..", "input", "AB->ABBB.txt"))
|
||||
expected_result = execute(graph, particles_2_4)
|
||||
|
||||
@testset "AB->ABBB no optimization" begin
|
||||
for _ in 1:5 # test in a loop because graph layout should not change the result
|
||||
graph = parse_abc(joinpath(@__DIR__, "..", "input", "AB->ABBB.txt"))
|
||||
@test isapprox(
|
||||
execute(graph, particles_2_4),
|
||||
expected_result;
|
||||
rtol = 0.001,
|
||||
)
|
||||
|
||||
code = MetagraphOptimization.gen_code(graph)
|
||||
@test isapprox(
|
||||
execute(code, particles_2_4),
|
||||
expected_result;
|
||||
rtol = 0.001,
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@testset "AB->ABBB after random walk" begin
|
||||
for i in 1:10
|
||||
graph = parse_abc(joinpath(@__DIR__, "..", "input", "AB->ABBB.txt"))
|
||||
random_walk!(graph, 20)
|
||||
@test is_valid(graph)
|
||||
|
||||
@test isapprox(
|
||||
execute(graph, particles_2_4),
|
||||
expected_result;
|
||||
rtol = 0.001,
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
println("Execution Unit Tests Complete!")
|
||||
|
Reference in New Issue
Block a user