Skip to content

Commit 886cc8f

Browse files
committed
now it passes
1 parent b25d5ef commit 886cc8f

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

pyaml/tuning_tools/orbit.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,18 @@ def correct(
9898
trims = trims_v
9999
corr_array = self._vcorr
100100

101-
corrector_was_used = {key: False for key in trims.keys()}
102101
corrector_names = corr_array.names()
102+
corrector_to_index = {name: idx for idx, name in enumerate(corrector_names)}
103103
data_to_send = corr_array.strengths.get()
104-
for idx, name in enumerate(corrector_names):
105-
data_to_send[idx] += trims[name] * gain
106-
corrector_was_used[name] = True
107-
108-
# check that all corrector trims will be sent
109-
for key in trims.keys():
110-
if not corrector_was_used[key]:
104+
for name in trims.keys():
105+
idx = corrector_to_index.get(name, None)
106+
if idx is None:
111107
raise PyAMLException(
112-
f"Corrector {key} was not used in the orbit correction. "
113-
"There is an inconcistency between corrector arrays and "
108+
f"Corrector {name} not found in the magnet array for orbit corr. "
109+
"Possible inconcistency between corrector arrays and "
114110
"response matrix."
115111
)
112+
data_to_send[idx] += trims[name] * gain
116113

117114
corr_array.strengths.set(data_to_send)
118115
return

0 commit comments

Comments
 (0)