From 1132ee1d6d24b39d04ecb85251a345be8bda3aab Mon Sep 17 00:00:00 2001 From: Nomos11 <82180697+Nomos11@users.noreply.github.com> Date: Fri, 31 May 2024 14:42:31 +0200 Subject: [PATCH 1/6] linspace time sweep barebone test --- tests/program/linspace_tests.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/program/linspace_tests.py b/tests/program/linspace_tests.py index 03a5b297..541afa91 100644 --- a/tests/program/linspace_tests.py +++ b/tests/program/linspace_tests.py @@ -287,3 +287,23 @@ def test_local_trafo_program(self): global_transformation=self.transformation, to_single_waveform={self.pulse_template}) self.assertEqual([self.program], program) + + +class TimeSweepTest(TestCase): + def setUp(self,base_time=1e2,rep_factor=2): + wait = ConstantPT(f'64*{base_time}*1e1*(1+idx_t)', {'a': '-1. + idx_a * 0.01', 'b': '-.5 + idx_b * 0.02'}) + + random_constant = ConstantPT(10 ** 5, {'a': -.4, 'b': -.3}) + meas = ConstantPT(64*base_time, {'a': 0.05, 'b': 0.06}) + + singlet_scan = (random_constant @ wait @ meas).with_iteration('idx_a', rep_factor*10*2)\ + .with_iteration('idx_b', rep_factor*10)\ + .with_iteration('idx_t', 10) + self.pulse_template = singlet_scan + + + def test_singlet_scan_program(self): + program_builder = LinSpaceBuilder(('a', 'b')) + program = self.pulse_template.create_program(program_builder=program_builder) + # so far just a test to see if the program creation works at all. + # self.assertEqual([self.program], program) \ No newline at end of file From 4d2fdb9c0851eb82f304071ff0977eaacdeb5c8e Mon Sep 17 00:00:00 2001 From: Nomos11 <82180697+Nomos11@users.noreply.github.com> Date: Fri, 31 May 2024 20:18:20 +0200 Subject: [PATCH 2/6] barebone test for pulse metadata --- tests/program/pulse_metadata_test.py | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/program/pulse_metadata_test.py diff --git a/tests/program/pulse_metadata_test.py b/tests/program/pulse_metadata_test.py new file mode 100644 index 00000000..b344b28b --- /dev/null +++ b/tests/program/pulse_metadata_test.py @@ -0,0 +1,31 @@ +import copy +import unittest +from unittest import TestCase + +from qupulse.pulses import * +from qupulse.program.linspace import * +from qupulse.program.transformation import * + + +class PulseMetaDataTest(TestCase): + def setUp(self): + hold_a = ConstantPT(10 ** 6, {'a': '-1. + idx * 0.01'}) + hold_b = ConstantPT(10 ** 6, {'a': '-0.2 + idx * 0.005'}) + hold_combined = SequencePT(hold_a,hold_b,identifier='hold_pt') + hold_2 = ConstantPT(10 ** 6, {'a': '-0.5'}) + play_arbitrary = FunctionPT("tanh(a*t**2 + b*t + c) * sin(b*t + c) + cos(a*t)/2",192*1e5,channel="a") + + self.pulse_template = (hold @ play_arbitrary @ hold_2).with_iteration('idx', 200) + + self.pulse_metadata = { + 'hold_pt': PTMetaData(True,2.0), + hold_2: PTMetaData(to_single_waveform=False,minimal_sample_rate=1e-10,), + play_arbitrary: PTMetaData(False,1e-3) + } + + def test_program(self): + program_builder = LinSpaceBuilder(('a',)) + program = self.pulse_template.create_program( + program_builder=program_builder, + metadata=self.pulse_metadata + ) From 49d9a2da4bc538e1e5c29e5f4862fa6d746a1870 Mon Sep 17 00:00:00 2001 From: Nomos11 <82180697+Nomos11@users.noreply.github.com> Date: Fri, 31 May 2024 20:55:51 +0200 Subject: [PATCH 3/6] update test with to_increment_commands --- tests/program/linspace_tests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/program/linspace_tests.py b/tests/program/linspace_tests.py index 541afa91..ff8662fb 100644 --- a/tests/program/linspace_tests.py +++ b/tests/program/linspace_tests.py @@ -302,8 +302,9 @@ def setUp(self,base_time=1e2,rep_factor=2): self.pulse_template = singlet_scan - def test_singlet_scan_program(self): + def test_time_sweep_program(self): program_builder = LinSpaceBuilder(('a', 'b')) program = self.pulse_template.create_program(program_builder=program_builder) + commands = to_increment_commands(program) # so far just a test to see if the program creation works at all. # self.assertEqual([self.program], program) \ No newline at end of file From 2f8f36921e0fa2ce6c7943f1b4b28cdebe0f4e43 Mon Sep 17 00:00:00 2001 From: Nomos11 <82180697+Nomos11@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:39:15 +0200 Subject: [PATCH 4/6] rename test file --- tests/program/{pulse_metadata_test.py => pulse_metadata_tests.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/program/{pulse_metadata_test.py => pulse_metadata_tests.py} (100%) diff --git a/tests/program/pulse_metadata_test.py b/tests/program/pulse_metadata_tests.py similarity index 100% rename from tests/program/pulse_metadata_test.py rename to tests/program/pulse_metadata_tests.py From 3ac3b9b2e42790487ffbbfd51554a0091ecc842f Mon Sep 17 00:00:00 2001 From: Nomos11 <82180697+Nomos11@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:48:21 +0200 Subject: [PATCH 5/6] add init to program tests --- tests/program/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/program/__init__.py diff --git a/tests/program/__init__.py b/tests/program/__init__.py new file mode 100644 index 00000000..e69de29b From 23999024c48bf6c187e547a0fb29d70ca3fb913f Mon Sep 17 00:00:00 2001 From: Nomos11 <82180697+Nomos11@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:56:58 +0200 Subject: [PATCH 6/6] adapt test setup --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index a77b1e90..76b607da 100644 --- a/setup.cfg +++ b/setup.cfg @@ -71,7 +71,7 @@ qctoolkit = *.pyi [tool:pytest] -testpaths = tests tests/pulses tests/hardware tests/backward_compatibility +testpaths = tests tests/pulses tests/hardware tests/backward_compatibility tests/_program tests/expressions tests/program tests/utils python_files=*_tests.py *_bug.py filterwarnings = # syntax is action:message_regex:category:module_regex:lineno