Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing tests for new linspace&sample rate features #827

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Empty file added tests/program/__init__.py
Empty file.
21 changes: 21 additions & 0 deletions tests/program/linspace_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,24 @@ 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_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)
31 changes: 31 additions & 0 deletions tests/program/pulse_metadata_tests.py
Original file line number Diff line number Diff line change
@@ -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
)
Loading