<jupyter_start><jupyter_text>Using the Scheduler Basic usage<jupyter_code>import numpy as np

from qiskit import IBMQ, QuantumCircuit, transpile, schedule as build_schedule
from qiskit import circuit
from qiskit.pulse import Schedule, Gaussian, SamplePulse, DriveChannel, ControlChannel
from qiskit.test.mock import FakeAlmaden
circ = QuantumCircuit(1, 1)
circ = QuantumCircuit(2, 2)
circ.h(0)
circ.cx(0, 1)
circ.measure([0, 1], [0, 1])

circ.draw()<jupyter_output><empty_output><jupyter_text>TODO<jupyter_code>backend = FakeAlmaden()

transpiled_circ = transpile(circ, backend)
schedule = build_schedule(transpiled_circ, backend)
schedule.draw()<jupyter_output><empty_output><jupyter_text>Scheduling with custom gate definitions<jupyter_code>custom_q0_h_schedule = Schedule(Gaussian(duration=128, amp=0.045, sigma=8)(DriveChannel(0)))

inst_map = backend.defaults().instruction_schedule_map
inst_map.add('h', 0, custom_q0_h_schedule)

schedule = build_schedule(circ, backend, inst_map=inst_map)<jupyter_output>/opt/miniconda3/lib/python3.7/site-packages/qiskit_terra-0.14.0-py3.7-macosx-10.9-x86_64.egg/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `Gaussian` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(Gaussian(duration=128, amp=(0.045+0j), sigma=8), DriveChannel(0))`.
  DeprecationWarning)<jupyter_text>Building circuits with non-standard gatesDesign a new gate by giving it a name, specific qubits, and a pulse `Schedule` definition.<jupyter_code>from qiskit.pulse.schedule import ParameterizedSchedule

random_pulse = lambda x: SamplePulse(np.random.random(max(x, 1)))

def my_perfect_2q_gate_schedule_func(x):
    sched = Schedule()
    sched += random_pulse(x)(DriveChannel(0))
    sched += random_pulse(x)(ControlChannel(0))
    sched += random_pulse(x)(DriveChannel(1))
    return sched

my_perfect_2q_gate_schedule = ParameterizedSchedule(my_perfect_2q_gate_schedule_func, parameters=('x'))<jupyter_output><empty_output><jupyter_text>Add definition to instruction map<jupyter_code>inst_map.add('my_perfect_2q_gate', (0, 1), my_perfect_2q_gate_schedule)<jupyter_output><empty_output><jupyter_text>Build schedule as usual<jupyter_code>my_perfect_2q_gate = circuit.Gate('my_perfect_2q_gate', 2, [100])

my_perfect_2q_circ = QuantumCircuit(2, 2)
my_perfect_2q_circ.h(0)
my_perfect_2q_circ.append(my_perfect_2q_gate, [0, 1])
my_perfect_2q_circ.h(0)
my_perfect_2q_circ.measure(0, 0)

my_perfect_2q_circ.draw()<jupyter_output><empty_output><jupyter_text>Transpile with the new gate<jupyter_code>my_perfect_2q_circ_transpiled = transpile(my_perfect_2q_circ,
                                          coupling_map=[[0, 1]],
                                          basis_gates=backend.configuration().basis_gates + ['my_perfect_2q_gate'])
my_perfect_2q_circ_transpiled.draw()
my_perfect_2q_pulse_program = build_schedule(my_perfect_2q_circ_transpiled,
                                             backend,
                                             inst_map=inst_map)
my_perfect_2q_pulse_program.draw(plot_range=(0, 2000))<jupyter_output>/opt/miniconda3/lib/python3.7/site-packages/qiskit_terra-0.14.0-py3.7-macosx-10.9-x86_64.egg/qiskit/pulse/pulse_lib/sample_pulse.py:153: DeprecationWarning: Calling `SamplePulse` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(SamplePulse(samples), DriveChannel(0))`.
  DeprecationWarning)
/opt/miniconda3/lib/python3.7/site-packages/qiskit_terra-0.14.0-py3.7-macosx-10.9-x86_64.egg/qiskit/pulse/pulse_lib/pulse.py:49: DeprecationWarning: Calling `SamplePulse` with a channel is deprecated. Instantiate the new `Play` instruction directly with a pulse and a channel. In this case, please use: `Play(SamplePulse(array([0.30110631+0.j, 0.10810737+0.j, 0.03998606+0.j, 0.31636986+0.j,
       0.61695352+0.j, 0.46061295+0.j, 0.20461338+0.j, 0.31296634+0.j,
       0.3620973 +0.j, 0.35520896+0.j, 0.34029644+0.j, 0.98193977+0.j,
       0.8320206 +0.j, 0.29558013+0.j, 0.53739644+0.j, 0.49689595+0.j,
       0.255657[...]
{'fraction_non_alphanumeric': 0.11679884643114635, 'fraction_numerical': 0.07209805335255948, 'mean_word_length': 5.363914373088685, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '309093', 'license': 'Apache-2.0', 'n_tokens_mistral': 1724, 'n_tokens_neox': 1514, 'n_words': 256, 'path': 'legacy_tutorials/terra/4_pulse_scheduler.ipynb', 'repo_name': '708-145/qiskit-tutorials', 'size': '4161'}