Skip to content

Commit 06bf262

Browse files
Merge branch 'main' into project-formatting
2 parents fca7b23 + 94af97f commit 06bf262

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

pyaml/lattice/abstract_impl.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,12 @@ class BPMScalarAggregator(ScalarAggregator):
173173
BPM simulator aggregator
174174
"""
175175

176-
def __init__(self, ring: at.Lattice):
177-
self.__lattice = ring
178-
self.__refpts = []
176+
def __init__(self, ring:at.Lattice):
177+
self.lattice = ring
178+
self.refpts = []
179179

180-
def add_elem(self, elem: at.Element):
181-
self.__refpts.append(self.__lattice.index(elem))
180+
def add_elem(self,elem:at.Element):
181+
self.refpts.append(self.lattice.index(elem))
182182

183183
def set(self, value: NDArray[np.float64]):
184184
pass
@@ -187,7 +187,7 @@ def set_and_wait(self, value: NDArray[np.float64]):
187187
pass
188188

189189
def get(self) -> np.array:
190-
_, orbit = at.find_orbit(self.__lattice, refpts=self.__refpts)
190+
_, orbit = at.find_orbit(self.lattice, refpts=self.refpts)
191191
return orbit[:, [0, 2]].flatten()
192192

193193
def readback(self) -> np.array:
@@ -200,26 +200,26 @@ def unit(self) -> str:
200200
# ------------------------------------------------------------------------------
201201

202202

203-
class BPMVScalarAggregator(BPMScalarAggregator):
203+
class BPMHScalarAggregator(BPMScalarAggregator):
204204
"""
205205
Vertical BPM simulator aggregator
206206
"""
207207

208208
def get(self) -> np.array:
209-
_, orbit = at.find_orbit(self.__lattice, refpts=self.__refpts)
209+
_, orbit = at.find_orbit(self.lattice, refpts=self.refpts)
210210
return orbit[:, 0]
211211

212212

213213
# ------------------------------------------------------------------------------
214214

215215

216-
class BPMHScalarAggregator(BPMScalarAggregator):
216+
class BPMVScalarAggregator(BPMScalarAggregator):
217217
"""
218218
Horizontal BPM simulator aggregator
219219
"""
220220

221221
def get(self) -> np.array:
222-
_, orbit = at.find_orbit(self.__lattice, refpts=self.__refpts)
222+
_, orbit = at.find_orbit(self.lattice, refpts=self.refpts)
223223
return orbit[:, 2]
224224

225225

tests/test_arrays.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,19 @@ def test_arrays(install_test_package):
116116

117117
# Test BPMs array
118118

119-
# Using aggragtor
119+
# Using aggregator
120120
pos = sr.design.get_bpms("BPMS").positions.get()
121121
assert np.abs(pos[0][0] + 7.21154171490481e-05) < 1e-10
122122
assert np.abs(pos[0][1] - 3.3988843436571406e-05) < 1e-10
123123
assert np.abs(pos[1][0] - 1.1681211772781844e-04) < 1e-10
124124
assert np.abs(pos[1][1] - 7.072972488250373e-06) < 1e-10
125125

126+
# Using aggregator (h and v)
127+
pos_h = sr.design.get_bpms("BPMS").h.get()
128+
pos_v = sr.design.get_bpms("BPMS").v.get()
129+
assert np.all(np.isclose(pos[:, 0], pos_h, rtol=1e-15, atol=1e-15))
130+
assert np.all(np.isclose(pos[:, 1], pos_v, rtol=1e-15, atol=1e-15))
131+
126132
# No aggregator
127133
bpms = []
128134
for b in sr.design.get_bpms("BPMS"):

0 commit comments

Comments
 (0)