Exemplo n.º 1
0
    def test_get_parameter_from_complex_schedule(self):
        """Test get parameters from complicated schedule."""
        test_block = deepcopy(self.test_sched)

        visitor = ParameterGetter()
        visitor.visit(test_block)

        self.assertEqual(len(visitor.parameters), 17)
Exemplo n.º 2
0
    def test_get_parameter_from_pulse(self):
        """Test get parameters from pulse instruction."""
        test_obj = self.parametric_waveform1

        visitor = ParameterGetter()
        visitor.visit(test_obj)

        ref_params = {self.amp1_1, self.amp1_2, self.dur1}

        self.assertSetEqual(visitor.parameters, ref_params)
Exemplo n.º 3
0
    def test_get_parameter_from_alignment_context(self):
        """Test get parameters from alignment context."""
        test_obj = AlignEquispaced(duration=self.context_dur + self.dur1)

        visitor = ParameterGetter()
        visitor.visit(test_obj)

        ref_params = {self.context_dur, self.dur1}

        self.assertSetEqual(visitor.parameters, ref_params)
Exemplo n.º 4
0
    def test_get_parameter_from_channel(self):
        """Test get parameters from channel."""
        test_obj = pulse.DriveChannel(self.ch1 + self.ch2)

        visitor = ParameterGetter()
        visitor.visit(test_obj)

        ref_params = {self.ch1, self.ch2}

        self.assertSetEqual(visitor.parameters, ref_params)
Exemplo n.º 5
0
    def test_get_parameter_from_inst(self):
        """Test get parameters from instruction."""
        test_obj = pulse.ShiftPhase(self.phi1 + self.phi2,
                                    pulse.DriveChannel(0))

        visitor = ParameterGetter()
        visitor.visit(test_obj)

        ref_params = {self.phi1, self.phi2}

        self.assertSetEqual(visitor.parameters, ref_params)
    def test_get_parameter_from_acquire(self):
        """Test get parameters from acquire instruction."""
        test_obj = pulse.Acquire(16000, pulse.AcquireChannel(self.ch1),
                                 pulse.MemorySlot(self.ch1))

        visitor = ParameterGetter()
        visitor.visit(test_obj)

        ref_params = {self.ch1}

        self.assertSetEqual(visitor.parameters, ref_params)
Exemplo n.º 7
0
    def test_get_parameter_from_call(self):
        """Test get parameters from instruction."""
        sched = pulse.Schedule()
        sched += pulse.ShiftPhase(self.phi1, self.d1)

        test_obj = pulse.Call(subroutine=sched)

        visitor = ParameterGetter()
        visitor.visit(test_obj)

        ref_params = {self.phi1, self.ch1}

        self.assertSetEqual(visitor.parameters, ref_params)
    def test_with_function(self):
        """Test ParameterExpressions formed trivially in a function."""
        def get_shift(variable):
            return variable - 1

        test_obj = pulse.ShiftPhase(get_shift(self.phi1), self.d1)

        visitor = ParameterGetter()
        visitor.visit(test_obj)

        ref_params = {self.phi1, self.ch1}

        self.assertSetEqual(visitor.parameters, ref_params)