def test_build_from_config2(self): # Test rebuilding a sequence including a template sequence. # Channel mapping of template_vars values are known. conf = {'template_id': 'test', 'name': 'Template', 'template_vars': "{'b': '25'}"} seq = TemplateSequence.build_from_config(conf, self.dependecies) seq.context.channel_mapping = {'A': 'Ch1_L', 'B': 'Ch2_L', 'Ch1': 'Ch2_A', 'Ch2': 'Ch1_A'} root = RootSequence() context = TestContext(sampling=0.5) root.context = context root.items = [seq] pref = root.preferences_from_members() new = RootSequence.build_from_config(pref, self.dependecies) assert_equal(new.items[0].index, 1) seq = new.items[0] assert_equal(seq.name, 'Template') assert_equal(seq.template_id, 'test') assert_equal(seq.template_vars, dict(b='25')) assert_equal(seq.local_vars, dict(a='1.5')) assert_equal(len(seq.items), 4) assert_equal(seq.items[3].index, 5) assert_equal(seq.docs, 'Basic user comment\nff') context = seq.context assert_equal(context.template, seq) assert_equal(context.logical_channels, ['A', 'B']) assert_equal(context.analogical_channels, ['Ch1', 'Ch2']) assert_equal(context.channel_mapping, {'A': 'Ch1_L', 'B': 'Ch2_L', 'Ch1': 'Ch2_A', 'Ch2': 'Ch1_A'})
def test_sequence_time_constaints_observation(): # Test adding, moving, deleting pulse in a sequence. root = RootSequence() context = TestContext() root.context = context sequence = Sequence() root.items = [sequence] assert_equal(root.linkable_vars, []) sequence.time_constrained = True assert_items_equal(root.linkable_vars, ['1_start', '1_stop', '1_duration']) sequence.time_constrained = False assert_equal(root.linkable_vars, [])
def test_collect_dependencies(self): # Test collecting build dependencies. self.workbench.register(PulsesManagerManifest()) from hqc_meas.pulses.base_sequences import RootSequence, Sequence from hqc_meas.pulses.pulse import Pulse from hqc_meas.pulses.shapes.base_shapes import SquareShape from hqc_meas.pulses.contexts.awg_context import AWGContext root = RootSequence(context=AWGContext()) pulse1 = Pulse(def_1='1.0', def_2='{7_start} - 1.0') pulse2 = Pulse(def_1='{a} + 1.0', def_2='{6_start} + 1.0') pulse3 = Pulse(def_1='{3_stop} + 0.5', def_2='10.0') pulse4 = Pulse(def_1='2.0', def_2='0.5', def_mode='Start/Duration') pulse5 = Pulse(def_1='{1_stop}', def_2='0.5', def_mode='Start/Duration') pulse5.shape = SquareShape(amplitude='0.5') pulse5.kind = 'Analogical' pulse5.modulation.frequency = '1.0**' pulse5.modulation.phase = '1.0' pulse5.modulation.activated = True sequence2 = Sequence(items=[pulse3]) sequence1 = Sequence(items=[pulse2, sequence2, pulse4]) root.items = [pulse1, sequence1, pulse5] core = self.workbench.get_plugin(u'enaml.workbench.core') com = u'hqc_meas.dependencies.collect_dependencies' res, build, run = core.invoke_command(com, {'obj': root}, core) assert_true(res) assert_in('pulses', build) assert_items_equal(['Sequence', 'Pulse', 'RootSequence', 'shapes', 'contexts', 'templates', 'sequences'], build['pulses'].keys()) assert_equal(['SquareShape'], build['pulses']['shapes'].keys()) assert_equal(['AWGContext'], build['pulses']['contexts'].keys()) assert_false(run)