Skip to content

Commit fc178a4

Browse files
committed
Switch tests to use I04 instead of deleted HMBA
1 parent d7f2397 commit fc178a4

File tree

2 files changed

+27
-56
lines changed

2 files changed

+27
-56
lines changed

tests/conftest.py

Lines changed: 14 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def atlds():
6464

6565
@pytest.fixture()
6666
def at_lattice():
67-
return atip.utils.load_at_lattice("HMBA")
67+
return atip.utils.load_at_lattice("I04")
6868

6969

7070
@pytest.fixture(scope="session")
@@ -123,52 +123,21 @@ def ba_atsim(at_lattice):
123123

124124

125125
@pytest.fixture()
126-
def initial_phys_data(at_lattice):
126+
def initial_phys_data(atsim):
127127
return {
128-
"tune": numpy.array([0.38156245, 0.85437543]),
129-
"chromaticity": numpy.array([0.17919002, 0.12242263]),
130-
"closed_orbit": numpy.zeros((6, len(at_lattice))),
131-
"dispersion": numpy.array(
132-
[1.72682010e-3, 4.04368254e-9, 5.88659608e-28, -8.95277691e-29]
128+
"tune": numpy.array([atsim.get_tune("x"), atsim.get_tune("y")]),
129+
"chromaticity": numpy.array(
130+
[atsim.get_chromaticity("x"), atsim.get_chromaticity("y")]
133131
),
132+
"closed_orbit": numpy.zeros((6, len(atsim._at_lat))),
133+
"dispersion": atsim.get_dispersion()[-1],
134134
"s_pos": numpy.cumsum(
135-
[0.0] + [getattr(elem, "Length", 0) for elem in at_lattice[:-1]]
136-
),
137-
"alpha": numpy.array([0.384261343, 1.00253822]),
138-
"beta": numpy.array([7.91882634, 5.30280084]),
139-
"m66": numpy.array(
140-
[
141-
[-0.47537132, 6.62427828, 0.0, 0.0, 2.55038448e-03, -5.33885495e-07],
142-
[-0.09816788, -0.73565385, 0.0, 0.0, 1.69015229e-04, -3.53808533e-08],
143-
[0.0, 0.0, -0.18476435, -3.7128728, 0.0, 0.0],
144-
[0.0, 0.0, 0.29967874, 0.60979916, 0.0, 0.0],
145-
[
146-
1.24684834e-06,
147-
2.15443495e-05,
148-
0.0,
149-
0.0,
150-
9.99980691e-01,
151-
2.09331256e-04,
152-
],
153-
[
154-
1.70098195e-04,
155-
2.99580152e-03,
156-
0.0,
157-
0.0,
158-
2.24325864e-03,
159-
9.99999530e-01,
160-
],
161-
]
162-
),
163-
"mu": numpy.array([14.59693301, 4.58153046, 6.85248778e-04]),
164-
"emitXY": numpy.array([1.32528e-10, 0.0]),
165-
"rad_int": numpy.array(
166-
[
167-
2.2435734416179783e-3,
168-
4.3264360771244244e-3,
169-
1.049245018317141e-4,
170-
-2.3049140720439194e-3,
171-
1.6505019559193616e-8,
172-
]
135+
[0.0] + [getattr(elem, "Length", 0) for elem in atsim._at_lat[:-1]]
173136
),
137+
"alpha": atsim.get_alpha()[-1],
138+
"beta": atsim.get_beta()[-1],
139+
"m66": atsim.get_m66()[-1],
140+
"mu": atsim.get_mu()[-1],
141+
"emitXY": numpy.array([atsim.get_emittance("x"), atsim.get_emittance("y")]),
142+
"rad_int": atsim.get_radiation_integrals(),
174143
}

tests/test_at_simulator_object.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,21 +137,21 @@ def test_gather_one_sample(atsim):
137137
def test_recalculate_phys_data(atsim, initial_phys_data):
138138
_check_initial_phys_data(atsim, initial_phys_data)
139139
# Check that errors raised inside thread are converted to warnings.
140-
atsim._at_lat[5].PolynomB[0] = 1.0e10
140+
atsim._at_lat[4].PolynomB[0] = 1.0e10
141141
atsim.queue_set(mock.Mock(), "f", 0)
142142
with pytest.warns(at.AtWarning):
143143
atsim.wait_for_calculations()
144-
atsim._at_lat[5].PolynomB[0] = 0.0
144+
atsim._at_lat[4].PolynomB[0] = 0.0
145145
# Set corrector x_kick but on a sextupole as no correctors in test ring
146-
atsim._at_lat[21].PolynomB[0] = -7.0e-5
146+
atsim._at_lat[7].PolynomB[0] = -7.0e-5
147147
# Set corrector y_kick but on a sextupole as no correctors in test ring
148-
atsim._at_lat[21].PolynomA[0] = 7.0e-5
148+
atsim._at_lat[7].PolynomA[0] = 7.0e-5
149149
# Set quadrupole b1
150-
atsim._at_lat[5].PolynomB[1] = 2.5
150+
atsim._at_lat[4].PolynomB[1] = -0.8
151151
# Set skew quadrupole a1
152-
atsim._at_lat[7].PolynomA[1] = 2.25e-3
152+
atsim._at_lat[10].PolynomA[1] = 2.25e-3
153153
# Set sextupole b2
154-
atsim._at_lat[21].PolynomB[2] = -75
154+
atsim._at_lat[7].PolynomB[2] = 10
155155
# Clear the flag and then wait for the calculations
156156
atsim.queue_set(mock.Mock(), "f", 0)
157157
atsim.wait_for_calculations()
@@ -164,8 +164,8 @@ def test_recalculate_phys_data(atsim, initial_phys_data):
164164
numpy.testing.assert_almost_equal(
165165
orbit, [5.18918914e-06, -8.92596857e-06], decimal=3
166166
)
167-
numpy.testing.assert_almost_equal(chrom, [0.11732846, 0.04300947], decimal=2)
168-
numpy.testing.assert_almost_equal(tune, [0.37444833, 0.86048592], decimal=3)
167+
numpy.testing.assert_almost_equal(chrom, [1.89, 4.64], decimal=2)
168+
numpy.testing.assert_almost_equal(tune, [0.133, 0.307], decimal=3)
169169
numpy.testing.assert_almost_equal(emit, [1.34308653e-10, 3.74339964e-13], decimal=3)
170170

171171

@@ -196,7 +196,8 @@ def test_toggle_calculations_and_wait_for_calculations(atsim, initial_phys_data)
196196
assert not atsim._paused
197197
# pause > make a change > check no calc > unpause > check calc
198198
atsim.toggle_calculations()
199-
atsim._at_lat[5].PolynomB[1] = 2.5
199+
# Kick quadrupole
200+
atsim._at_lat[4].PolynomB[1] = -0.8
200201
atsim.queue_set(mock.Mock(), "f", 0)
201202
assert atsim.wait_for_calculations(2) is False
202203
_check_initial_phys_data(atsim, initial_phys_data)
@@ -335,7 +336,8 @@ def test_get_radiation_integrals(mocked_atsim):
335336

336337
def test_get_momentum_compaction(mocked_atsim, at_lattice):
337338
numpy.testing.assert_almost_equal(
338-
0.08196721311475409, mocked_atsim.get_momentum_compaction()
339+
mocked_atsim.get_momentum_compaction(),
340+
0.0045641,
339341
)
340342

341343

0 commit comments

Comments
 (0)