def test_zero_duration(self): p1 = ConstantPulseTemplate(10, {'P1': 1.}) p2 = ConstantPulseTemplate(0, {'P1': 1.}) p3 = ConstantPulseTemplate(2, {'P1': 1.}) _ = qupulse.pulses.plotting.render(p1.create_program()) pulse = SequencePulseTemplate(p1, p2, p3) prog = pulse.create_program() _ = qupulse.pulses.plotting.render(prog) self.assertEqual(pulse.duration, 12)
def integrated_test_with_sequencer_and_pulse_templates(self) -> None: # Setup test data square = TablePulseTemplate() square.add_entry('up', 'v', 'hold') square.add_entry('down', 0, 'hold') square.add_entry('length', 0) mapping1 = { 'up': 'uptime', 'down': 'uptime + length', 'v': 'voltage', 'length': '0.5 * pulse_length' } outer_parameters = ['uptime', 'length', 'pulse_length', 'voltage'] parameters = {} parameters['uptime'] = 5 parameters['length'] = 10 parameters['pulse_length'] = 100 parameters['voltage'] = 10 sequence = SequencePulseTemplate([(square, mapping1), (square, mapping1)], outer_parameters) # render the plot sample_rate = 20 program = sequence.create_program(parameters=parameters) times, voltages = render(program, sample_rate=sample_rate) # compute expected values expected_times = numpy.linspace(0, 100, sample_rate) expected_voltages = numpy.zeros_like(expected_times) expected_voltages[100:300] = numpy.ones(200) * parameters['voltage'] # compare self.assertEqual(expected_times, times) self.assertEqual(expected_voltages, voltages)