Ejemplo n.º 1
0
    def test_basic(self):
        p1 = AbortingGetter('p1', count=2, vals=Numbers(-10, 10), set_cmd=None)
        sv = p1[1:3:1]
        loop = Loop(sv)

        # not sure why you'd do it, but you *can* snapshot a Loop
        expected = {
            '__class__': 'qcodes.loops.Loop',
            'sweep_values': sv.snapshot(),
            'delay': 0,
            'then_actions': []
        }
        self.assertEqual(loop.snapshot(), expected)
        loop = loop.then(Task(p1.set, 0), Wait(0.123))
        expected['then_actions'] = [{
            'type': 'Task',
            'func': repr(p1.set)
        }, {
            'type': 'Wait',
            'delay': 0.123
        }]

        # then test snapshot on an ActiveLoop
        breaker = BreakIf(lambda: p1.get_latest() > 3)
        self.assertEqual(breaker.snapshot()['type'], 'BreakIf')
        loop = loop.each(p1, breaker)
        expected['__class__'] = 'qcodes.loops.ActiveLoop'
        expected['actions'] = [p1.snapshot(), breaker.snapshot()]

        self.assertEqual(loop.snapshot(), expected)
Ejemplo n.º 2
0
    def test_basic(self):
        p1 = AbortingGetter('p1', count=2, vals=Numbers(-10, 10))
        sv = p1[1:3:1]
        loop = Loop(sv)

        # not sure why you'd do it, but you *can* snapshot a Loop
        expected = {
            '__class__': 'qcodes.loops.Loop',
            'sweep_values': sv.snapshot(),
            'delay': 0,
            'then_actions': []
        }
        self.assertEqual(loop.snapshot(), expected)
        loop = loop.then(Task(p1.set, 0), Wait(0.123))
        expected['then_actions'] = [{
            'type': 'Task',
            'func': repr(p1.set)
        }, {
            'type': 'Wait',
            'delay': 0.123
        }]

        # then test snapshot on an ActiveLoop
        breaker = BreakIf(p1.get_latest > 3)
        self.assertEqual(breaker.snapshot()['type'], 'BreakIf')
        # TODO: once we have reprs for DeferredOperations, test that
        # the right thing shows up in breaker.snapshot()['condition']
        loop = loop.each(p1, breaker)
        expected['__class__'] = 'qcodes.loops.ActiveLoop'
        expected['actions'] = [p1.snapshot(), breaker.snapshot()]

        self.assertEqual(loop.snapshot(), expected)