replace(old, new, inplace=False)¶
oldinstruction replaced with a
The replacement matching is based on an instruction equality check.
from qiskit import pulse d0 = pulse.DriveChannel(0) sched = pulse.Schedule() old = pulse.Play(pulse.Constant(100, 1.0), d0) new = pulse.Play(pulse.Constant(100, 0.1), d0) sched += old sched = sched.replace(old, new) assert sched == pulse.Schedule(new)
Only matches at the top-level of the schedule tree. If you wish to perform this replacement over all instructions in the schedule tree. Flatten the schedule prior to running:
sched = pulse.Schedule()
sched += pulse.Schedule(old)
sched = sched.flatten()
sched = sched.replace(old, new)
assert sched == pulse.Schedule(new)
Instruction]) – Instruction to replace.
Instruction]) – Instruction to replace with.
bool) – Replace instruction by mutably modifying this
- Return type
The modified schedule with
PulseError – If the
Scheduleafter replacements will has a timing overlap.