Skip to content

Commit

Permalink
Add singlet reload test
Browse files Browse the repository at this point in the history
  • Loading branch information
terrorfisch committed Jun 21, 2024
1 parent e598e8c commit e2801ff
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion tests/program/linspace_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


def assert_vm_output_almost_equal(test: TestCase, expected, actual):
"""Compare two vm outputs with default TestCase.assertAlmostEqual accuracy"""
test.assertEqual(len(expected), len(actual))
for idx, ((t_e, vals_e), (t_a, vals_a)) in enumerate(zip(expected, actual)):
test.assertEqual(t_e, t_a, f"Differing times in {idx} element")
Expand Down Expand Up @@ -59,7 +60,6 @@ def test_output(self):
vm = LinSpaceVM(1)
vm.set_commands(commands=self.commands)
vm.run()
self.assertEqual(self.output, vm.history)
assert_vm_output_almost_equal(self, self.output, vm.history)


Expand Down Expand Up @@ -309,6 +309,23 @@ def setUp(self):
LoopJmp(1),
]

self.output = []
time = TimeType(0)
for idx_b in range(100):
for idx_a in range(200):
self.output.append(
(time, [-.4, -.3])
)
time += 10 ** 5
self.output.append(
(time, [-1. + idx_a * 0.01, -.5 + idx_b * 0.02])
)
time += 10 ** 6
self.output.append(
(time, [0.05, 0.06])
)
time += 10 ** 5

def test_singlet_scan_program(self):
program_builder = LinSpaceBuilder(('a', 'b'))
program = self.pulse_template.create_program(program_builder=program_builder)
Expand All @@ -318,6 +335,12 @@ def test_singlet_scan_commands(self):
commands = to_increment_commands([self.program])
self.assertEqual(self.commands, commands)

def test_singlet_scan_output(self):
vm = LinSpaceVM(2)
vm.set_commands(self.commands)
vm.run()
assert_vm_output_almost_equal(self, self.output, vm.history)


class TransformedRampTest(TestCase):
def setUp(self):
Expand Down

0 comments on commit e2801ff

Please sign in to comment.