Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix aperture_check method of the Line class. #534

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
8 changes: 6 additions & 2 deletions tests/test_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ def test_to_pandas():
def test_check_aperture():

class ThickElement:

length = 2.
isthick = True

Expand All @@ -380,11 +379,16 @@ class ThickElement:
'th3_ap_front': xt.LimitEllipse(a=1e-2, b=1e-2),
'th3': ThickElement(),
'dr6': xt.Drift(length=1),
'th4_ap_entry': xt.LimitEllipse(a=1e-2, b=1e-2),
'th4': ThickElement(),
'th4_ap_exit': xt.LimitEllipse(a=1e-2, b=1e-2),
},
element_names=['dr1', 'm1_ap', 'dum', 'm1', 'dr2', 'm2', 'dr3',
'th1_ap_front', 'dum', 'th1', 'dum', 'th1_ap_back',
'dr4', 'th2', 'th2_ap_back',
'dr5', 'th3_ap_front', 'th3'])
'dr5', 'th3_ap_front', 'th3', 'dr6',
'th4_ap_entry', 'th4', 'th4_ap_exit'])

df = line.check_aperture()

expected_miss_upstream = [nn in ('m2', 'th2') for nn in df['name'].values]
Expand Down
6 changes: 3 additions & 3 deletions xtrack/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -3213,13 +3213,13 @@ def check_aperture(self, needs_aperture=[]):
i_next_aperture = 0

for iee in progress(range(i_prev_aperture, num_elements), desc='Checking aperture'):
if dont_need_aperture[elements_df.loc[iee, 'name']]:
continue

if elements_df.loc[iee, 'is_aperture']:
i_prev_aperture = iee
continue

if dont_need_aperture[elements_df.loc[iee, 'name']]:
continue

if i_next_aperture < iee:
for ii in range(iee, num_elements):
if elements_df.loc[ii, 'is_aperture']:
Expand Down