예제 #1
0
    def __matmul__(
        self, other: Union['PulseTemplate',
                           MappingTuple]) -> 'SequencePulseTemplate':
        """This method enables using the @-operator (intended for matrix multiplication) for
         concatenating pulses. If one of the pulses is a SequencePulseTemplate the other pulse gets merged into it"""
        from qupulse.pulses.sequence_pulse_template import SequencePulseTemplate

        return SequencePulseTemplate.concatenate(self, other)
    def test_concatenate(self):
        a = DummyPulseTemplate(parameter_names={'foo'}, defined_channels={'A'})
        b = DummyPulseTemplate(parameter_names={'bar'}, defined_channels={'A'})

        spt_anon = SequencePulseTemplate(a, b)
        spt_id = SequencePulseTemplate(a, b, identifier='id')
        spt_meas = SequencePulseTemplate(a, b, measurements=[('m', 0, 'd')])
        spt_constr = SequencePulseTemplate(a, b, parameter_constraints=['a < b'])

        merged = SequencePulseTemplate.concatenate(a, spt_anon, b)
        self.assertEqual(merged.subtemplates, [a, a, b, b])

        result = SequencePulseTemplate.concatenate(a, spt_id, b)
        self.assertEqual(result.subtemplates, [a, spt_id, b])

        result = SequencePulseTemplate.concatenate(a, spt_meas, b)
        self.assertEqual(result.subtemplates, [a, spt_meas, b])

        result = SequencePulseTemplate.concatenate(a, spt_constr, b)
        self.assertEqual(result.subtemplates, [a, spt_constr, b])
예제 #3
0
    def __rmatmul__(self, other: MappingTuple) -> 'SequencePulseTemplate':
        from qupulse.pulses.sequence_pulse_template import SequencePulseTemplate

        return SequencePulseTemplate.concatenate(other, self)