Skip to content

Commit ca49410

Browse files
committed
Meaningful tolerances
1 parent 8b42bdc commit ca49410

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

test/test_transmon_expanded.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
from c3.model import Model
1818
import pytest
1919

20+
ATOL_SIG = 1e-8 # for comparing signals 10 nV
21+
ATOL_FREQ = 1e3 # for comparing frequencies 1 KHz
22+
2023
freq_q1 = 5e9
2124
freq_q2 = 6e9
2225
fluxpoint1 = 0
@@ -193,22 +196,22 @@ def test_signals():
193196
np.testing.assert_allclose(
194197
actual=test_data["signal_q1"]["ts"],
195198
desired=data["signal_q1"]["ts"],
196-
atol=1e-8,
199+
atol=ATOL_SIG,
197200
)
198201
np.testing.assert_allclose(
199202
actual=test_data["signal_q1"]["values"],
200203
desired=data["signal_q1"]["values"],
201-
atol=1e-8,
204+
atol=ATOL_SIG,
202205
)
203206
np.testing.assert_allclose(
204207
actual=test_data["signal_q2"]["ts"],
205208
desired=data["signal_q2"]["ts"],
206-
atol=1e-8,
209+
atol=ATOL_SIG,
207210
)
208211
np.testing.assert_allclose(
209212
actual=test_data["signal_q2"]["values"].numpy(),
210213
desired=data["signal_q2"]["values"].numpy(),
211-
atol=1e-8,
214+
atol=ATOL_SIG,
212215
)
213216

214217

@@ -235,13 +238,13 @@ def test_hamiltonians():
235238
np.testing.assert_allclose(
236239
actual=test_data["hamiltonians_q1"],
237240
desired=data["hamiltonians_q1"],
238-
atol=1e-9 * np.max(data["hamiltonians_q1"]),
241+
atol=ATOL_FREQ,
239242
)
240243

241244
np.testing.assert_allclose(
242245
actual=test_data["hamiltonians_q2"],
243246
desired=data["hamiltonians_q2"],
244-
atol=1e-11 * np.max(data["hamiltonians_q2"]),
247+
atol=ATOL_FREQ,
245248
)
246249

247250

@@ -260,23 +263,23 @@ def test_propagation():
260263
np.testing.assert_allclose(
261264
actual=test_data["propagators_q1"],
262265
desired=data["propagators_q1"],
263-
atol=1e-12,
266+
atol=ATOL_FREQ,
264267
)
265268
np.testing.assert_allclose(
266269
actual=test_data["partial_propagators_q1"],
267270
desired=data["partial_propagators_q1"],
268-
atol=1e-12,
271+
atol=ATOL_FREQ,
269272
)
270273

271274
np.testing.assert_allclose(
272275
actual=test_data["propagators_q2"],
273276
desired=data["propagators_q2"],
274-
atol=1e-12,
277+
atol=ATOL_FREQ,
275278
)
276279
np.testing.assert_allclose(
277280
actual=test_data["partial_propagators_q2"],
278281
desired=data["partial_propagators_q2"],
279-
atol=1e-12,
282+
atol=ATOL_FREQ,
280283
)
281284

282285

0 commit comments

Comments
 (0)