Skip to content

Commit 0a94dad

Browse files
committed
Make it more robust
1 parent 8e1d3c7 commit 0a94dad

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

python_examples/hl_lhc_collisions_python/checks_and_doc/t004_check_output_consistency.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
'path_ref': '../',
3131
'type_ref': 'sixtrack',
3232
'rtol': 4e-7,
33-
'atol': 1e-100,
33+
'atol': 1e-13,
3434
'strict': True,
3535
}
3636
]
@@ -238,9 +238,13 @@ def prepare_line(path, input_type):
238238
'mcbch.5r2.b2', 'mcbch.a5r2.b2', 'mcbyh.4r2.b2', 'mcbxh.3r2',
239239
'mcbyh.a4l2.b2', 'mcbyh.5l2.b2', 'mcbyv.5r8.b2', 'mcbyv.a4r8.b2',
240240
'mcbxv.3r8', 'mcbyv.4l8.b2', 'mcbcv.b5l8.b2']:
241-
if nn_corr in nn_test and diff_rel < 1e-2:
242-
passed_corr = True
243-
break
241+
if nn_corr in nn_test and kk in ['knl','ksl','bal']:
242+
assert len(val_ref)<=2
243+
assert len(val_test)<=2
244+
diff_rel = norm(val_test-val_ref)/norm(val_ref)
245+
passed_corr = (diff_rel < 1e-2)
246+
if passed_corr:
247+
break
244248
if not(strict) and passed_corr:
245249
continue
246250

@@ -285,7 +289,14 @@ def prepare_line(path, input_type):
285289
if kk == "px_co" or kk == 'py_co':
286290
if diff_abs <30e-9:
287291
continue
288-
292+
if isinstance(ee_test, xt.XYShift):
293+
if kk in ['dx','dy']:
294+
if diff_abs <1e-9:
295+
continue
296+
if isinstance(ee_test, xt.SRotation):
297+
if kk in ['sin_z', 'cos_z', 'angle']:
298+
if diff_abs <1e-9:
299+
continue
289300
# If it got here it means that no condition above is met
290301
raise ValueError("Too large discrepancy!")
291302
print(

0 commit comments

Comments
 (0)