def setUp(self) -> None: # define some building blocks self.sin_pt = FunctionPT('sin(omega*t)', 't_duration', channel='X') self.cos_pt = FunctionPT('sin(omega*t)', 't_duration', channel='Y') self.exp_pt = AtomicMultiChannelPT(self.sin_pt, self.cos_pt) self.tpt = TablePT({'X': [(0, 0), (3., 4.), ('t_duration', 2., 'linear')], 'Y': [(0, 1.), ('t_y', 5.), ('t_duration', 0., 'linear')]}) self.complex_pt = RepetitionPT(self.tpt, 5) @ self.exp_pt self.parameters = dict(t_duration=10, omega=3.14*2/10, t_y=3.4)
def test_issue_451(self): from qupulse.pulses import TablePT, SequencePT, AtomicMultiChannelPT gates_template = TablePT({'gate': [(0, 1), (60 * 1e3, 2, 'hold')]}) input_variables = {'period': float(gates_template.duration), 'uptime': 0} marker_sequence = (TablePT({'m': [(0, 1), ('uptime', 0), ('period', 0)]}), input_variables) combined_template = AtomicMultiChannelPT(gates_template, marker_sequence) combined_template.create_program() marker_sequence2 = TablePT({'m': [(0, 1), (0, 0), (gates_template.duration, 0)]}) combined_template2 = AtomicMultiChannelPT(gates_template, marker_sequence2) combined_template2.create_program()
def test_regression_template_combination(self): old_value = qupulse.utils.sympy.SYMPY_DURATION_ERROR_MARGIN try: qupulse.utils.sympy.SYMPY_DURATION_ERROR_MARGIN = 1e-9 duration_in_seconds = 2e-6 full_template = ConstantPulseTemplate(duration=duration_in_seconds * 1e9, amplitude_dict={'C1': 1.1}) duration_in_seconds_derived = 1e-9 * full_template.duration marker_pulse = TablePT({'marker': [(0, 0), (duration_in_seconds_derived * 1e9, 0)]}) full_template = AtomicMultiChannelPT(full_template, marker_pulse) finally: qupulse.utils.sympy.SYMPY_DURATION_ERROR_MARGIN = old_value
def get_pulse_template(self) -> PulseTemplate: fpt = FunctionPT('sin(omega*t)', 't_duration', 'X', measurements=[('M', 0, 't_duration')]) tpt = TablePT( { 'Y': [(0, 'a'), ('t_duration', 2)], 'Z': [('t_duration', 1)] }, measurements=[('N', 0, 't_duration/2')]) mpt = MappingPT(fpt, parameter_mapping={'omega': '2*pi/t_duration'}, allow_partial_parameter_mapping=True) ampt = AtomicMultiChannelPT(mpt, tpt) body = ampt @ ampt rpt = RepetitionPT(body, 'N_rep', measurements=[('O', 0, 1)]) forpt = ForLoopPT(rpt, 'a', '6') final = SequencePT(rpt, forpt) return final