Skip to content

Commit a844685

Browse files
author
Uwe Hernandez Acosta
committed
formatting
1 parent be17cb5 commit a844685

9 files changed

+200
-187
lines changed

src/cross_sections.jl

+8-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,14 @@ function _differential_cross_section(
120120
# if (!isapprox(sum(in_phase_space), sum(out_phase_space); rtol=sqrt(eps())))
121121
# return zero(eltype(T))
122122
# end
123-
if !_is_in_phasespace(proc, model, in_phase_space_def, in_phase_space, out_phase_space_def, out_phase_space)
123+
if !_is_in_phasespace(
124+
proc,
125+
model,
126+
in_phase_space_def,
127+
in_phase_space,
128+
out_phase_space_def,
129+
out_phase_space,
130+
)
124131
return zero(eltype(T))
125132
end
126133

src/interfaces/process_interface.jl

-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ end
123123
"""
124124
function _averaging_norm end
125125

126-
127126
"""
128127
129128
_is_in_phasespace(

src/probabilities.jl

+9-2
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,15 @@ function _probability(
119119
# if (!isapprox(sum(in_phase_space), sum(out_phase_space); rtol=sqrt(eps())))
120120
# return zero(eltype(T))
121121
# end
122-
123-
if !_is_in_phasespace(proc, model, in_phase_space_def, in_phase_space, out_phase_space_def, out_phase_space)
122+
123+
if !_is_in_phasespace(
124+
proc,
125+
model,
126+
in_phase_space_def,
127+
in_phase_space,
128+
out_phase_space_def,
129+
out_phase_space,
130+
)
124131
return zero(eltype(T))
125132
end
126133

test/cross_sections.jl

+105-111
Original file line numberDiff line numberDiff line change
@@ -9,127 +9,127 @@ RTOL = sqrt(eps())
99
include("utils/utils.jl")
1010

1111
@testset "($N_INCOMING,$N_OUTGOING)" for (N_INCOMING, N_OUTGOING) in Iterators.product(
12-
(1, rand(RNG, 2:8)), (1, rand(RNG, 2:8))
12+
(1, rand(RNG, 2:8)), (1, rand(RNG, 2:8))
1313
)
1414
INCOMING_PARTICLES = rand(RNG, PARTICLE_SET, N_INCOMING)
1515
OUTGOING_PARTICLES = rand(RNG, PARTICLE_SET, N_OUTGOING)
1616

1717
QEDprocesses.incoming_particles(::TestProcess) = INCOMING_PARTICLES
1818
QEDprocesses.outgoing_particles(::TestProcess) = OUTGOING_PARTICLES
1919

20-
# single ps points
21-
p_in_phys= _rand_momenta(RNG, N_INCOMING)
22-
p_in_phys_invalid = _rand_momenta(RNG, N_INCOMING+1)
23-
p_in_unphys = _rand_momenta_failed(RNG,N_INCOMING)
24-
p_in_unphys_invalid = _rand_momenta_failed(RNG,N_INCOMING+1)
25-
p_out_phys= _rand_momenta(RNG, N_OUTGOING)
26-
p_out_phys_invaid = _rand_momenta(RNG, N_OUTGOING+1)
27-
28-
# sets of ps points
29-
p_in_set_phys= _rand_momenta(RNG, N_INCOMING, 2)
30-
p_in_set_unphys_mix = _rand_momenta_failed_mix(RNG,N_INCOMING,2)
31-
p_in_set_unphys_all = _rand_momenta_failed_all(RNG,N_INCOMING,2)
32-
p_in_set_phys_invalid = _rand_momenta(RNG, N_INCOMING+1, 2)
33-
p_in_set_unphys_mix_invalid = _rand_momenta_failed_mix(RNG,N_INCOMING+1,2)
34-
p_in_set_unphys_all_invalid = _rand_momenta_failed_all(RNG,N_INCOMING+1,2)
35-
p_out_set_phys = _rand_momenta(RNG, N_OUTGOING, 2)
36-
p_out_set_phys_invalid = _rand_momenta(RNG, N_OUTGOING+1, 2)
37-
38-
p_in_all = (p_in_phys, p_in_unphys,
39-
p_in_phys_invalid,p_in_unphys_invalid,
40-
p_in_set_phys, p_in_set_unphys_mix, p_in_set_unphys_all,
41-
p_in_set_phys_invalid, p_in_set_unphys_mix_invalid, p_in_set_unphys_all_invalid)
42-
43-
p_out_all = (p_out_phys,
44-
p_out_phys_invaid,
45-
p_out_set_phys,
46-
p_out_set_phys_invalid)
47-
# all combinations
48-
p_combs = Iterators.product(p_in_all,p_out_all)
49-
50-
p_in_all_valid = (p_in_phys, p_in_unphys,
51-
p_in_set_phys, p_in_set_unphys_mix, p_in_set_unphys_all)
52-
53-
p_out_all_valid = (p_out_phys, p_out_set_phys)
54-
55-
# all valid combinations
56-
p_combs_valid = collect(Iterators.product(p_in_all_valid,p_out_all_valid))
57-
58-
p_in_all_phys = (p_in_phys,p_in_set_phys)
59-
p_out_all_phys = (p_out_phys,p_out_set_phys)
60-
61-
p_combs_phys = Iterators.product(p_in_all_phys, p_out_all_phys)
62-
20+
# single ps points
21+
p_in_phys = _rand_momenta(RNG, N_INCOMING)
22+
p_in_phys_invalid = _rand_momenta(RNG, N_INCOMING + 1)
23+
p_in_unphys = _rand_momenta_failed(RNG, N_INCOMING)
24+
p_in_unphys_invalid = _rand_momenta_failed(RNG, N_INCOMING + 1)
25+
p_out_phys = _rand_momenta(RNG, N_OUTGOING)
26+
p_out_phys_invaid = _rand_momenta(RNG, N_OUTGOING + 1)
27+
28+
# sets of ps points
29+
p_in_set_phys = _rand_momenta(RNG, N_INCOMING, 2)
30+
p_in_set_unphys_mix = _rand_momenta_failed_mix(RNG, N_INCOMING, 2)
31+
p_in_set_unphys_all = _rand_momenta_failed_all(RNG, N_INCOMING, 2)
32+
p_in_set_phys_invalid = _rand_momenta(RNG, N_INCOMING + 1, 2)
33+
p_in_set_unphys_mix_invalid = _rand_momenta_failed_mix(RNG, N_INCOMING + 1, 2)
34+
p_in_set_unphys_all_invalid = _rand_momenta_failed_all(RNG, N_INCOMING + 1, 2)
35+
p_out_set_phys = _rand_momenta(RNG, N_OUTGOING, 2)
36+
p_out_set_phys_invalid = _rand_momenta(RNG, N_OUTGOING + 1, 2)
37+
38+
p_in_all = (
39+
p_in_phys,
40+
p_in_unphys,
41+
p_in_phys_invalid,
42+
p_in_unphys_invalid,
43+
p_in_set_phys,
44+
p_in_set_unphys_mix,
45+
p_in_set_unphys_all,
46+
p_in_set_phys_invalid,
47+
p_in_set_unphys_mix_invalid,
48+
p_in_set_unphys_all_invalid,
49+
)
50+
51+
p_out_all = (p_out_phys, p_out_phys_invaid, p_out_set_phys, p_out_set_phys_invalid)
52+
# all combinations
53+
p_combs = Iterators.product(p_in_all, p_out_all)
54+
55+
p_in_all_valid = (
56+
p_in_phys, p_in_unphys, p_in_set_phys, p_in_set_unphys_mix, p_in_set_unphys_all
57+
)
58+
59+
p_out_all_valid = (p_out_phys, p_out_set_phys)
60+
61+
# all valid combinations
62+
p_combs_valid = collect(Iterators.product(p_in_all_valid, p_out_all_valid))
63+
64+
p_in_all_phys = (p_in_phys, p_in_set_phys)
65+
p_out_all_phys = (p_out_phys, p_out_set_phys)
66+
67+
p_combs_phys = Iterators.product(p_in_all_phys, p_out_all_phys)
68+
6369
@testset "cross section" begin
6470
@testset "unsafe" begin
6571
@testset "compute" begin
66-
for (P_IN,P_OUT) in p_combs_phys
72+
for (P_IN, P_OUT) in p_combs_phys
6773
diffCS = unsafe_differential_cross_section(
6874
TestProcess(),
6975
TestModel(),
7076
TestPhasespaceDef(),
7177
P_IN,
7278
TestPhasespaceDef(),
73-
P_OUT
79+
P_OUT,
7480
)
7581
groundtruth = _groundtruth_unsafe_diffCS(TestProcess(), P_IN, P_OUT)
7682
@test isapprox(diffCS, groundtruth, atol=ATOL, rtol=RTOL)
7783
end
7884
end
7985

8086
@testset "invalid input" begin
81-
for (P_IN,P_OUT) in p_combs
87+
for (P_IN, P_OUT) in p_combs
8288

8389
# filter out all valid combinations
84-
if !((P_IN,P_OUT) in p_combs_valid)
90+
if !((P_IN, P_OUT) in p_combs_valid)
8591
@test_throws DimensionMismatch unsafe_differential_cross_section(
8692
TestProcess(),
8793
TestModel(),
8894
TestPhasespaceDef(),
8995
P_IN,
9096
TestPhasespaceDef(),
91-
P_OUT
97+
P_OUT,
9298
)
93-
9499
end
95-
96100
end
97101
end
98102
end
99103
@testset "safe" begin
100104
@testset "compute" begin
101-
102-
for (P_IN,P_OUT) in p_combs_valid
105+
for (P_IN, P_OUT) in p_combs_valid
103106
diffCS = differential_cross_section(
104107
TestProcess(),
105108
TestModel(),
106109
TestPhasespaceDef(),
107110
P_IN,
108111
TestPhasespaceDef(),
109-
P_OUT
112+
P_OUT,
110113
)
111114
groundtruth = _groundtruth_safe_diffCS(TestProcess(), P_IN, P_OUT)
112115
@test isapprox(diffCS, groundtruth, atol=ATOL, rtol=RTOL)
113116
end
114117
end
115118

116-
117119
@testset "invalid input" begin
118-
for (P_IN,P_OUT) in p_combs
120+
for (P_IN, P_OUT) in p_combs
119121

120122
# filter out all valid combinations
121-
if !((P_IN,P_OUT) in p_combs_valid)
123+
if !((P_IN, P_OUT) in p_combs_valid)
122124
@test_throws DimensionMismatch differential_cross_section(
123125
TestProcess(),
124126
TestModel(),
125127
TestPhasespaceDef(),
126128
P_IN,
127129
TestPhasespaceDef(),
128-
P_OUT
130+
P_OUT,
129131
)
130-
131132
end
132-
133133
end
134134
end
135135
end
@@ -165,75 +165,69 @@ include("utils/utils.jl")
165165
# end
166166
# end
167167
end
168-
168+
169169
@testset "probability" begin
170-
@testset "unsafe compute" begin
171-
for (P_IN,P_OUT) in p_combs_phys
172-
prob = unsafe_probability(
170+
@testset "unsafe compute" begin
171+
for (P_IN, P_OUT) in p_combs_phys
172+
prob = unsafe_probability(
173+
TestProcess(),
174+
TestModel(),
175+
TestPhasespaceDef(),
176+
P_IN,
177+
TestPhasespaceDef(),
178+
P_OUT,
179+
)
180+
groundtruth = _groundtruth_unsafe_probability(TestProcess(), P_IN, P_OUT)
181+
@test isapprox(prob, groundtruth, atol=ATOL, rtol=RTOL)
182+
end
183+
end
184+
185+
@testset "unsafe invalid input" begin
186+
for (P_IN, P_OUT) in p_combs
187+
188+
# filter out all valid combinations
189+
if !((P_IN, P_OUT) in p_combs_valid)
190+
@test_throws DimensionMismatch unsafe_probability(
173191
TestProcess(),
174192
TestModel(),
175193
TestPhasespaceDef(),
176194
P_IN,
177195
TestPhasespaceDef(),
178-
P_OUT
196+
P_OUT,
179197
)
180-
groundtruth = _groundtruth_unsafe_probability(TestProcess(), P_IN, P_OUT)
181-
@test isapprox(prob, groundtruth, atol=ATOL, rtol=RTOL)
182198
end
183199
end
184-
185-
@testset "unsafe invalid input" begin
186-
for (P_IN,P_OUT) in p_combs
187-
188-
# filter out all valid combinations
189-
if !((P_IN,P_OUT) in p_combs_valid)
190-
@test_throws DimensionMismatch unsafe_probability(
191-
TestProcess(),
192-
TestModel(),
193-
TestPhasespaceDef(),
194-
P_IN,
195-
TestPhasespaceDef(),
196-
P_OUT
197-
)
198-
199-
end
200-
201-
end
200+
end
201+
@testset "safe compute" begin
202+
for (P_IN, P_OUT) in p_combs_valid
203+
prob = probability(
204+
TestProcess(),
205+
TestModel(),
206+
TestPhasespaceDef(),
207+
P_IN,
208+
TestPhasespaceDef(),
209+
P_OUT,
210+
)
211+
groundtruth = _groundtruth_safe_probability(TestProcess(), P_IN, P_OUT)
212+
@test isapprox(prob, groundtruth, atol=ATOL, rtol=RTOL)
202213
end
203-
@testset "safe compute" begin
214+
end
215+
216+
@testset "safe invalid input" begin
217+
for (P_IN, P_OUT) in p_combs
204218

205-
for (P_IN,P_OUT) in p_combs_valid
206-
prob = probability(
219+
# filter out all valid combinations
220+
if !((P_IN, P_OUT) in p_combs_valid)
221+
@test_throws DimensionMismatch probability(
207222
TestProcess(),
208223
TestModel(),
209224
TestPhasespaceDef(),
210225
P_IN,
211226
TestPhasespaceDef(),
212-
P_OUT
227+
P_OUT,
213228
)
214-
groundtruth = _groundtruth_safe_probability(TestProcess(), P_IN, P_OUT)
215-
@test isapprox(prob, groundtruth, atol=ATOL, rtol=RTOL)
216-
end
217-
end
218-
219-
220-
@testset "safe invalid input" begin
221-
for (P_IN,P_OUT) in p_combs
222-
223-
# filter out all valid combinations
224-
if !((P_IN,P_OUT) in p_combs_valid)
225-
@test_throws DimensionMismatch probability(
226-
TestProcess(),
227-
TestModel(),
228-
TestPhasespaceDef(),
229-
P_IN,
230-
TestPhasespaceDef(),
231-
P_OUT
232-
)
233-
234-
end
235-
236229
end
237230
end
231+
end
238232
end
239233
end

test/interfaces/process_interface.jl

+1-3
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ end
7373
@test isapprox(test_matrix_element[i], groundtruth[i], atol=ATOL, rtol=RTOL)
7474
end
7575
end
76-
76+
7777
@testset "is in phasespace" begin
7878
@test QEDprocesses._is_in_phasespace(
7979
TestProcess(),
@@ -87,7 +87,6 @@ end
8787
IN_PS_unphysical = deepcopy(IN_PS)
8888
IN_PS_unphysical[1] = SFourMomentum(zeros(4))
8989

90-
9190
@test !QEDprocesses._is_in_phasespace(
9291
TestProcess(),
9392
TestModel(),
@@ -96,7 +95,6 @@ end
9695
TestPhasespaceDef(),
9796
OUT_PS,
9897
)
99-
10098
end
10199

102100
@testset "phase space factor" begin

0 commit comments

Comments
 (0)