|
10 | 10 | import xpart as xp |
11 | 11 | import xtrack as xt |
12 | 12 | import xobjects as xo |
13 | | -from xobjects.test_helpers import for_all_test_contexts |
14 | | -from xpart.test_helpers import flaky_assertions, retry |
| 13 | +from xobjects.test_helpers import for_all_test_contexts, fix_random_seed |
15 | 14 |
|
16 | 15 |
|
17 | 16 | @for_all_test_contexts |
18 | | -@retry() |
| 17 | +@fix_random_seed(7363444) |
19 | 18 | def test_pencil_with_absolute_cut(test_context): |
20 | 19 |
|
21 | 20 | num_particles = 10000 |
@@ -97,26 +96,24 @@ def test_pencil_with_absolute_cut(test_context): |
97 | 96 | sigma_v = np.sqrt(betv*nemitt_v |
98 | 97 | /particles._xobject.beta0[0]/particles._xobject.gamma0[0]) |
99 | 98 |
|
100 | | - with flaky_assertions(): |
101 | | - assert(np.isclose(np.min(np.abs(v)), abs(absolute_cut), atol=1e-7)) |
102 | | - assert(np.isclose(np.max(np.abs(v)), abs(absolute_cut) + sigma_v*pencil_dr_sigmas, |
103 | | - rtol=1e-3, atol=0)) |
| 99 | + assert(np.isclose(np.min(np.abs(v)), abs(absolute_cut), atol=1e-7)) |
| 100 | + assert(np.isclose(np.max(np.abs(v)), abs(absolute_cut) + sigma_v*pencil_dr_sigmas, |
| 101 | + rtol=1e-3, atol=0)) |
104 | 102 |
|
105 | | - i_tip = np.argmax(np.abs(v)) |
106 | | - assert np.isclose(pv[i_tip]/v[i_tip], -alfv/betv, atol=5e-4) |
| 103 | + i_tip = np.argmax(np.abs(v)) |
| 104 | + assert np.isclose(pv[i_tip]/v[i_tip], -alfv/betv, atol=5e-4) |
107 | 105 |
|
108 | | - if side == '+': |
109 | | - assert np.all(v >= 0) |
110 | | - else: |
111 | | - assert np.all(v <= 0) |
112 | | - |
113 | | - other_plane = {'x': 'y', 'y': 'x'}[plane] |
114 | | - w_norm = getattr(norm_coords, other_plane+'_norm') |
115 | | - pw_norm = getattr(norm_coords, 'p'+other_plane+'_norm') |
| 106 | + if side == '+': |
| 107 | + assert np.all(v >= 0) |
| 108 | + else: |
| 109 | + assert np.all(v <= 0) |
116 | 110 |
|
117 | | - xo.assert_allclose(w_in_sigmas, w_norm, 1e-12) |
118 | | - xo.assert_allclose(pw_in_sigmas, pw_norm, 1e-12) |
| 111 | + other_plane = {'x': 'y', 'y': 'x'}[plane] |
| 112 | + w_norm = getattr(norm_coords, other_plane+'_norm') |
| 113 | + pw_norm = getattr(norm_coords, 'p'+other_plane+'_norm') |
119 | 114 |
|
120 | | - assert(np.allclose(zeta, particles.zeta, atol=1e-12)) |
121 | | - assert(np.allclose(delta, particles.delta, atol=1e-12)) |
| 115 | + xo.assert_allclose(w_in_sigmas, w_norm, 1e-12) |
| 116 | + xo.assert_allclose(pw_in_sigmas, pw_norm, 1e-12) |
122 | 117 |
|
| 118 | + xo.assert_allclose(zeta, particles.zeta, atol=1e-12) |
| 119 | + xo.assert_allclose(delta, particles.delta, atol=1e-12) |
0 commit comments