Esempio n. 1
0
 def test_regression_sequencept_with_mappingpt(self):
     t1 = TablePT({'C1': [(0, 0), (100, 0)], 'C2': [(0, 1), (100, 1)]})
     t2 = ConstantPulseTemplate(200, {'C1': 2, 'C2': 3})
     qupulse_template = SequencePulseTemplate(t1, t2)
     channel_mapping = {'C1': None, 'C2': 'C2'}
     p = MappingPT(qupulse_template, channel_mapping=channel_mapping)
     plot(p)
     self.assertEqual(p.defined_channels, {'C2'})
Esempio n. 2
0
    def test_plot_empty_pulse(self) -> None:
        import matplotlib
        matplotlib.use(
            'svg'
        )  # use non-interactive backend so that test does not fail on travis

        pt = DummyPulseTemplate()
        with self.assertWarnsRegex(
                UserWarning,
                "empty",
                msg="plot() did not issue a warning for an empty pulse"):
            plot(pt, dict(), show=False)
Esempio n. 3
0
    def __qupulse_template_plot(sequence, sampling_rate, axes):
        """ Plots a qupulse sequence.

        Args:
            sequence (dict): a waveform dictionary with "type" value
            given by the used pulse library. The "wave" value should contain
            the actual wave-object.
            sampling_rate (float): a sample rate of the awg in samples per sec.
            axes: matplotlib Axes object the pulse will be drawn into if provided.
        """
        ns_sample_rate = sampling_rate / Sequencer.__sec_to_ns
        plot(sequence['wave'], sample_rate=ns_sample_rate, axes=axes, show=False)
Esempio n. 4
0
    def test_plotting_two_channel_function_pulse_after_two_channel_table_pulse_crash(
            self) -> None:
        """ successful if no crash -> no asserts """
        template = TablePulseTemplate(entries={
            'A': [(0, 0), ('ta', 'va', 'hold'), ('tb', 'vb', 'linear'),
                  ('tend', 0, 'jump')],
            'B': [(0, 0), ('ta', '-va', 'hold'), ('tb', '-vb', 'linear'),
                  ('tend', 0, 'jump')]
        },
                                      measurements=[('m', 0, 'ta'),
                                                    ('n', 'tb', 'tend-tb')])

        parameters = {
            'ta': 2,
            'va': 2,
            'tb': 4,
            'vb': 3,
            'tc': 5,
            'td': 11,
            'tend': 6
        }
        _ = plot(template,
                 parameters,
                 sample_rate=100,
                 show=False,
                 plot_measurements={'m', 'n'})

        repeated_template = RepetitionPulseTemplate(template, 'n_rep')
        sine_template = FunctionPulseTemplate('sin_a*sin(t)', '2*3.1415')
        two_channel_sine_template = AtomicMultiChannelPulseTemplate(
            (sine_template, {
                'default': 'A'
            }), (sine_template, {
                'default': 'B'
            }, {
                'sin_a': 'sin_b'
            }))
        sequence_template = SequencePulseTemplate(repeated_template,
                                                  two_channel_sine_template)
        #sequence_template = SequencePulseTemplate(two_channel_sine_template, repeated_template) # this was working fine

        sequence_parameters = dict(
            parameters)  # we just copy our parameter dict from before
        sequence_parameters[
            'n_rep'] = 4  # and add a few new values for the new params from the sine wave
        sequence_parameters['sin_a'] = 1
        sequence_parameters['sin_b'] = 2

        _ = plot(sequence_template,
                 parameters=sequence_parameters,
                 sample_rate=100,
                 show=False)
Esempio n. 5
0
    def test_plot_with_parameter_value_being_expression_string(self) -> None:
        """This is currently not supported but probably should be?"""
        sine_measurements = [('M', 't_duration/2', 't_duration')]
        sine = FunctionPulseTemplate('a*sin(omega*t)',
                                     't_duration',
                                     measurements=sine_measurements)
        sine_channel_mapping = dict(default='sin_channel')
        sine_measurement_mapping = dict(M='M_sin')
        remapped_sine = MappingPulseTemplate(
            sine,
            measurement_mapping=sine_measurement_mapping,
            channel_mapping=sine_channel_mapping)
        cos_measurements = [('M', 0, 't_duration/2')]
        cos = FunctionPulseTemplate('a*cos(omega*t)',
                                    't_duration',
                                    measurements=cos_measurements)
        cos_channel_mapping = dict(default='cos_channel')
        cos_measurement_mapping = dict(M='M_cos')
        remapped_cos = MappingPulseTemplate(
            cos,
            channel_mapping=cos_channel_mapping,
            measurement_mapping=cos_measurement_mapping)
        both = AtomicMultiChannelPulseTemplate(remapped_sine, remapped_cos)

        parameter_values = dict(omega=1.0, a=1.0, t_duration="2*pi")

        _ = plot(both, parameters=parameter_values, sample_rate=100)
Esempio n. 6
0
    def test_bug_422(self):
        import matplotlib
        matplotlib.use(
            'svg'
        )  # use non-interactive backend so that test does not fail on travis

        to_reload = [
            'qupulse._program._loop', 'qupulse.pulses.pulse_template',
            'qupulse.pulses.table_pulse_template'
        ]

        with mock.patch.dict(sys.modules, sys.modules.copy()):
            for module in to_reload:
                sys.modules.pop(module, None)
            for module in to_reload:
                sys.modules[module] = importlib.reload(
                    importlib.import_module(module))

            from qupulse.pulses.table_pulse_template import TablePulseTemplate

            pt = TablePulseTemplate({'X': [(0, 1), (1, 1)]})

            plot(pt, parameters={})