def test_table_sequence_sequencer_integration(self) -> None:
        t1 = TablePulseTemplate()
        t1.add_entry(2, 'foo')
        t1.add_entry(5, 0)

        t2 = TablePulseTemplate()
        t2.add_entry(4, 0)
        t2.add_entry(4.5, 'bar', 'linear')
        t2.add_entry(5, 0)

        seqt = SequencePulseTemplate([(t1, {'foo': 'foo'}), (t2, {'bar': '2 * hugo'})], {'foo', 'hugo'})

        with self.assertRaises(ParameterNotProvidedException):
            t1.requires_stop(dict(), dict())
        with self.assertRaises(ParameterNotProvidedException):
            t2.requires_stop(dict(), dict())
        self.assertFalse(seqt.requires_stop({}, {}))

        foo = DummyNoValueParameter()
        bar = DummyNoValueParameter()
        sequencer = Sequencer()
        sequencer.push(seqt, {'foo': foo, 'hugo': bar})
        instructions = sequencer.build()
        self.assertFalse(sequencer.has_finished())
        self.assertEqual(1, len(instructions))

        foo = DummyParameter(value=1.1)
        bar = DummyNoValueParameter()
        sequencer = Sequencer()
        sequencer.push(seqt, {'foo': foo, 'hugo': bar})
        instructions = sequencer.build()
        self.assertFalse(sequencer.has_finished())
        self.assertEqual(2, len(instructions))

        foo = DummyParameter(value=1.1)
        bar = DummyNoValueParameter()
        sequencer = Sequencer()
        sequencer.push(seqt, {'foo': bar, 'hugo': foo})
        instructions = sequencer.build()
        self.assertFalse(sequencer.has_finished())
        self.assertEqual(1, len(instructions))

        foo = DummyParameter(value=1.1)
        bar = DummyParameter(value=-0.2)
        sequencer = Sequencer()
        sequencer.push(seqt, {'foo': foo, 'hugo': bar})
        instructions = sequencer.build()
        self.assertTrue(sequencer.has_finished())
        self.assertEqual(3, len(instructions))
 def test_requires_stop(self) -> None:
     table = TablePulseTemplate()
     foo_decl = ParameterDeclaration('foo', min=1)
     bar_decl = ParameterDeclaration('bar')
     table.add_entry(foo_decl, 'v', 'linear')
     table.add_entry(bar_decl, 0, 'jump')
     test_sets = [(False, {'foo': DummyParameter(0, False), 'bar': DummyParameter(0, False), 'v': DummyParameter(0, False)}, {'foo': DummyCondition(False)}),
                  (False, {'foo': DummyParameter(0, False), 'bar': DummyParameter(0, False), 'v': DummyParameter(0, False)}, {'foo': DummyCondition(True)}),
                  (True, {'foo': DummyParameter(0, True), 'bar': DummyParameter(0, False), 'v': DummyParameter(0, False)}, {'foo': DummyCondition(False)}),
                  (True, {'foo': DummyParameter(0, True), 'bar': DummyParameter(0, False), 'v': DummyParameter(0, False)}, {'foo': DummyCondition(True)}),
                  (True, {'foo': DummyParameter(0, False), 'bar': DummyParameter(0, False), 'v': DummyParameter(0, True)}, {'foo': DummyCondition(False)}),
                  (True, {'foo': DummyParameter(0, False), 'bar': DummyParameter(0, False), 'v': DummyParameter(0, True)}, {'foo': DummyCondition(True)}),
                  (True, {'foo': DummyParameter(0, True), 'bar': DummyParameter(0, True), 'v': DummyParameter(0, True)}, {'foo': DummyCondition(False)}),
                  (True, {'foo': DummyParameter(0, True), 'bar': DummyParameter(0, True), 'v': DummyParameter(0, True)}, {'foo': DummyCondition(True)})]
     for expected_result, parameter_set, condition_set in test_sets:
         self.assertEqual(expected_result, table.requires_stop(parameter_set, condition_set))
Esempio n. 3
0
 def test_requires_stop(self) -> None:
     table = TablePulseTemplate()
     foo_decl = ParameterDeclaration('foo', min=1)
     bar_decl = ParameterDeclaration('bar')
     table.add_entry(foo_decl, 'v', 'linear')
     table.add_entry(bar_decl, 0, 'jump')
     test_sets = [(False, {'foo': DummyParameter(0, False), 'bar': DummyParameter(0, False), 'v': DummyParameter(0, False)}, {'foo': DummyCondition(False)}),
                  (False, {'foo': DummyParameter(0, False), 'bar': DummyParameter(0, False), 'v': DummyParameter(0, False)}, {'foo': DummyCondition(True)}),
                  (True, {'foo': DummyParameter(0, True), 'bar': DummyParameter(0, False), 'v': DummyParameter(0, False)}, {'foo': DummyCondition(False)}),
                  (True, {'foo': DummyParameter(0, True), 'bar': DummyParameter(0, False), 'v': DummyParameter(0, False)}, {'foo': DummyCondition(True)}),
                  (True, {'foo': DummyParameter(0, False), 'bar': DummyParameter(0, False), 'v': DummyParameter(0, True)}, {'foo': DummyCondition(False)}),
                  (True, {'foo': DummyParameter(0, False), 'bar': DummyParameter(0, False), 'v': DummyParameter(0, True)}, {'foo': DummyCondition(True)}),
                  (True, {'foo': DummyParameter(0, True), 'bar': DummyParameter(0, True), 'v': DummyParameter(0, True)}, {'foo': DummyCondition(False)}),
                  (True, {'foo': DummyParameter(0, True), 'bar': DummyParameter(0, True), 'v': DummyParameter(0, True)}, {'foo': DummyCondition(True)})]
     for expected_result, parameter_set, condition_set in test_sets:
         self.assertEqual(expected_result, table.requires_stop(parameter_set, condition_set))
Esempio n. 4
0
    def test_table_sequence_sequencer_integration(self) -> None:
        t1 = TablePulseTemplate(entries={'default': [(2, 'foo'), (5, 0)]},
                                measurements=[('foo', 2, 2)])

        t2 = TablePulseTemplate(
            entries={'default': [(4, 0), (4.5, 'bar', 'linear'), (5, 0)]},
            measurements=[('foo', 4, 1)])

        seqt = SequencePulseTemplate(
            MappingPulseTemplate(t1, measurement_mapping={'foo': 'bar'}),
            MappingPulseTemplate(t2, parameter_mapping={'bar': '2 * hugo'}))

        with self.assertRaises(ParameterNotProvidedException):
            t1.requires_stop(dict(), dict())
        with self.assertRaises(ParameterNotProvidedException):
            t2.requires_stop(dict(), dict())
        self.assertFalse(
            seqt.requires_stop(
                {
                    'foo': DummyParameter(),
                    'hugo': DummyParameter()
                }, {}))

        foo = DummyNoValueParameter()
        bar = DummyNoValueParameter()
        sequencer = Sequencer()
        sequencer.push(seqt, {
            'foo': foo,
            'hugo': bar
        },
                       window_mapping=dict(bar='my', foo='thy'),
                       channel_mapping={'default': 'A'})
        instructions = sequencer.build()
        self.assertFalse(sequencer.has_finished())
        self.assertEqual(1, len(instructions))

        # stop after first TablePT
        foo = DummyParameter(value=1.1)
        bar = DummyNoValueParameter()
        sequencer = Sequencer()
        sequencer.push(seqt, {
            'foo': foo,
            'hugo': bar
        },
                       window_mapping=dict(bar='my', foo='thy'),
                       channel_mapping={'default': 'A'})
        instructions = sequencer.build()
        self.assertFalse(sequencer.has_finished())
        self.assertIsInstance(instructions, AbstractInstructionBlock)
        self.assertEqual(2, len(instructions.instructions))
        self.assertEqual(instructions[0], MEASInstruction([('my', 2, 2)]))
        self.assertIsInstance(instructions[1], EXECInstruction)

        # stop before first TablePT
        foo = DummyParameter(value=1.1)
        bar = DummyNoValueParameter()
        sequencer = Sequencer()
        sequencer.push(seqt, {
            'foo': bar,
            'hugo': foo
        },
                       window_mapping=dict(bar='my', foo='thy'),
                       channel_mapping={'default': 'A'})
        instructions = sequencer.build()
        self.assertFalse(sequencer.has_finished())
        self.assertEqual(1, len(instructions))

        foo = DummyParameter(value=1.1)
        bar = DummyParameter(value=-0.2)
        sequencer = Sequencer()
        sequencer.push(seqt, {
            'foo': foo,
            'hugo': bar
        },
                       window_mapping=dict(bar='my', foo='thy'),
                       channel_mapping={'default': 'A'})
        instructions = sequencer.build()
        self.assertTrue(sequencer.has_finished())
        self.assertEqual(4, len(instructions.instructions))

        self.assertEqual(instructions[0], MEASInstruction([('my', 2, 2)]))
        self.assertIsInstance(instructions[1], EXECInstruction)
        self.assertEqual(instructions[2], MEASInstruction([('thy', 4, 1)]))
        self.assertIsInstance(instructions[3], EXECInstruction)
Esempio n. 5
0
 def test_requires_stop_missing_param(self) -> None:
     table = TablePulseTemplate()
     foo_decl = ParameterDeclaration('foo')
     table.add_entry(foo_decl, 'v', 'linear')
     with self.assertRaises(ParameterNotProvidedException):
         table.requires_stop({'foo': DummyParameter(0, False)}, {})
Esempio n. 6
0
 def test_requires_stop(self) -> None:
     table = TablePulseTemplate({0: [('foo', 'v'), ('bar', 0)]})
     test_sets = [(False, {
         'foo': DummyParameter(0, False),
         'bar': DummyParameter(0, False),
         'v': DummyParameter(0, False)
     }, {
         'foo': DummyCondition(False)
     }),
                  (False, {
                      'foo': DummyParameter(0, False),
                      'bar': DummyParameter(0, False),
                      'v': DummyParameter(0, False)
                  }, {
                      'foo': DummyCondition(True)
                  }),
                  (True, {
                      'foo': DummyParameter(0, True),
                      'bar': DummyParameter(0, False),
                      'v': DummyParameter(0, False)
                  }, {
                      'foo': DummyCondition(False)
                  }),
                  (True, {
                      'foo': DummyParameter(0, True),
                      'bar': DummyParameter(0, False),
                      'v': DummyParameter(0, False)
                  }, {
                      'foo': DummyCondition(True)
                  }),
                  (True, {
                      'foo': DummyParameter(0, False),
                      'bar': DummyParameter(0, False),
                      'v': DummyParameter(0, True)
                  }, {
                      'foo': DummyCondition(False)
                  }),
                  (True, {
                      'foo': DummyParameter(0, False),
                      'bar': DummyParameter(0, False),
                      'v': DummyParameter(0, True)
                  }, {
                      'foo': DummyCondition(True)
                  }),
                  (True, {
                      'foo': DummyParameter(0, True),
                      'bar': DummyParameter(0, True),
                      'v': DummyParameter(0, True)
                  }, {
                      'foo': DummyCondition(False)
                  }),
                  (True, {
                      'foo': DummyParameter(0, True),
                      'bar': DummyParameter(0, True),
                      'v': DummyParameter(0, True)
                  }, {
                      'foo': DummyCondition(True)
                  })]
     for expected_result, parameter_set, condition_set in test_sets:
         self.assertEqual(expected_result,
                          table.requires_stop(parameter_set, condition_set))
Esempio n. 7
0
 def test_requires_stop_missing_param(self) -> None:
     table = TablePulseTemplate({0: [('foo', 'v')]})
     with self.assertRaises(ParameterNotProvidedException):
         table.requires_stop({'foo': DummyParameter(0, False)}, {})