qiskit.pulse.Schedule
class Schedule(*schedules, name=None)
A quantum program schedule with exact time constraints for its instructions, operating over all input signal channels and supporting special syntaxes for building.
Create an empty schedule.
Parameters
- *schedules – Child Schedules of this parent Schedule. May either be passed as the list of schedules, or a list of
(start_time, schedule)
pairs. - name (
Optional
[str
]) – Name of this schedule. Defaults to an autogenerated string if not provided.
__init__
__init__(*schedules, name=None)
Create an empty schedule.
Parameters
- *schedules – Child Schedules of this parent Schedule. May either be passed as the list of schedules, or a list of
(start_time, schedule)
pairs. - name (
Optional
[str
]) – Name of this schedule. Defaults to an autogenerated string if not provided.
Methods
__init__ (*schedules[, name]) | Create an empty schedule. |
append (schedule[, name, inplace]) | Return a new schedule with schedule inserted at the maximum time over all channels shared between self and schedule . |
assign_parameters (value_dict) | Assign the parameters in this schedule according to the input. |
ch_duration (*channels) | Return the time of the end of the last instruction over the supplied channels. |
ch_start_time (*channels) | Return the time of the start of the first instruction over the supplied channels. |
ch_stop_time (*channels) | Return maximum start time over supplied channels. |
draw ([dt, style, filename, interp_method, …]) | Plot the schedule. |
exclude (*filter_funcs[, channels, …]) | Return a Schedule with only the instructions from this Schedule failing at least one of the provided filters. This method is the complement of self.filter , so that::. |
filter (*filter_funcs[, channels, …]) | Return a new Schedule with only the instructions from this Schedule which pass though the provided filters; i.e. an instruction will be retained iff every function in filter_funcs returns True , the instruction occurs on a channel type contained in channels , the instruction type is contained in instruction_types , and the period over which the instruction operates is fully contained in one specified in time_ranges or intervals . |
flatten () | Return a new schedule which is the flattened schedule contained all instructions . |
insert (start_time, schedule[, name, inplace]) | Return a new schedule with schedule inserted into self at start_time . |
replace (old, new[, inplace]) | Return a schedule with the old instruction replaced with a new instruction. |
shift (time[, name, inplace]) | Return a schedule shifted forward by time . |
Attributes
channels | Returns channels that this schedule uses. |
duration | Duration of this schedule component. |
instances_counter | |
instructions | Get the time-ordered instructions from self. |
name | Name of ScheduleComponent. |
prefix | |
start_time | Starting time of this schedule component. |
stop_time | Stopping time of this schedule component. |
timeslots | Time keeping attribute. |
append
append(schedule, name=None, inplace=False)
Return a new schedule with schedule
inserted at the maximum time over all channels shared between self
and schedule
.
Parameters
- schedule (
ScheduleComponent
) – Schedule to be appended. - name (
Optional
[str
]) – Name of the newSchedule
. Defaults to name ofself
. - inplace (
bool
) – Perform operation inplace on this schedule. Otherwise return a newSchedule
.
Return type
Schedule
assign_parameters
assign_parameters(value_dict)
Assign the parameters in this schedule according to the input.
Parameters
value_dict (Dict
[ParameterExpression
, Union
[ParameterExpression
, float
, int
]]) – A mapping from Parameters to either numeric values or another Parameter expression.
Return type
Schedule
Returns
Schedule with updated parameters (a new one if not inplace, otherwise self).
ch_duration
ch_duration(*channels)
Return the time of the end of the last instruction over the supplied channels.
Parameters
*channels – Channels within self
to include.
Return type
int
ch_start_time
ch_start_time(*channels)
Return the time of the start of the first instruction over the supplied channels.
Parameters
*channels – Channels within self
to include.
Return type
int
ch_stop_time
ch_stop_time(*channels)
Return maximum start time over supplied channels.
Parameters
*channels – Channels within self
to include.
Return type
int
channels
draw
draw(dt=1, style=None, filename=None, interp_method=None, scale=None, channel_scales=None, plot_all=False, plot_range=None, interactive=False, table=False, label=False, framechange=True, channels=None, show_framechange_channels=True)
Plot the schedule.
Parameters
- dt (
float
) – Time interval of samples. - style (Optional[SchedStyle]) – A style sheet to configure plot appearance.
- filename (
Optional
[str
]) – Name required to save pulse image. - interp_method (
Optional
[Callable
]) – A function for interpolation. - scale (
Optional
[float
]) – Relative visual scaling of waveform amplitudes, see Additional Information. - channel_scales (
Optional
[Dict
[Channel
,float
]]) – Channel independent scaling as a dictionary ofChannel
object. - plot_all (
bool
) – Plot empty channels. - plot_range (
Optional
[Tuple
[float
]]) – A tuple of time range to plot. - interactive (
bool
) – When set true show the circuit in a new window (this depends on the matplotlib backend being used supporting this). - table (
bool
) – Draw event table for supported commands. - label (
bool
) – Label individual instructions. - framechange (
bool
) – Add framechange indicators. - channels (
Optional
[List
[Channel
]]) – A list of Channels to plot. - show_framechange_channels (
bool
) – Plot channels with only framechanges.
Additional Information:
If you want to manually rescale the waveform amplitude of channels one by one, you can set channel_scales
argument instead of scale
. The channel_scales
should be given as a python dictionary:
channel_scales = {pulse.DriveChannels(0): 10.0,
pulse.MeasureChannels(0): 5.0}
When the channel to plot is not included in the channel_scales
dictionary, scaling factor of that channel is overwritten by the value of scale
argument. In default, waveform amplitude is normalized by the maximum amplitude of the channel. The scaling factor is displayed under the channel name alias.
Returns
A matplotlib figure object of the pulse schedule.
Return type
matplotlib.Figure
duration
Duration of this schedule component.
Return type
int
exclude
exclude(*filter_funcs, channels=None, instruction_types=None, time_ranges=None, intervals=None)
Return a Schedule with only the instructions from this Schedule failing at least one of the provided filters. This method is the complement of self.filter
, so that:
self.filter(args) | self.exclude(args) == self
Parameters
- filter_funcs (
List
[Callable
]) – A list of Callables which take a (int, ScheduleComponent) tuple and return a bool. - channels (
Optional
[Iterable
[Channel
]]) – For example,[DriveChannel(0), AcquireChannel(0)]
. - instruction_types (Optional[Iterable[Type[qiskit.pulse.Instruction]]]) – For example,
[PulseInstruction, AcquireInstruction]
. - time_ranges (
Optional
[Iterable
[Tuple
[int
,int
]]]) – For example,[(0, 5), (6, 10)]
. - intervals (
Optional
[Iterable
[Tuple
[int
,int
]]]) – For example,[(0, 5), (6, 10)]
.
Return type
Schedule
filter
filter(*filter_funcs, channels=None, instruction_types=None, time_ranges=None, intervals=None)
Return a new Schedule
with only the instructions from this Schedule
which pass though the provided filters; i.e. an instruction will be retained iff every function in filter_funcs
returns True
, the instruction occurs on a channel type contained in channels
, the instruction type is contained in instruction_types
, and the period over which the instruction operates is fully contained in one specified in time_ranges
or intervals
.
If no arguments are provided, self
is returned.
Parameters
- filter_funcs (
List
[Callable
]) – A list of Callables which take a (int, ScheduleComponent) tuple and return a bool. - channels (
Optional
[Iterable
[Channel
]]) – For example,[DriveChannel(0), AcquireChannel(0)]
. - instruction_types (Optional[Iterable[Type[qiskit.pulse.Instruction]]]) – For example,
[PulseInstruction, AcquireInstruction]
. - time_ranges (
Optional
[Iterable
[Tuple
[int
,int
]]]) – For example,[(0, 5), (6, 10)]
. - intervals (
Optional
[Iterable
[Tuple
[int
,int
]]]) – For example,[(0, 5), (6, 10)]
.
Return type
Schedule
flatten
flatten()
Return a new schedule which is the flattened schedule contained all instructions
.
Return type
Schedule
insert
insert(start_time, schedule, name=None, inplace=False)
Return a new schedule with schedule
inserted into self
at start_time
.
Parameters
- start_time (
int
) – Time to insert the schedule. - schedule (
ScheduleComponent
) – Schedule to insert. - name (
Optional
[str
]) – Name of the new schedule. Defaults to the name of self. - inplace (
bool
) – Perform operation inplace on this schedule. Otherwise return a newSchedule
.
Return type
Schedule
instructions
Get the time-ordered instructions from self.
ReturnType:
Tuple[Tuple[int, Instruction], …]
name
Name of ScheduleComponent.
Return type
str
replace
replace(old, new, inplace=False)
Return a schedule with the old
instruction replaced with a new
instruction.
The replacment 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:
.. jupyter-execute::
sched = pulse.Schedule()
sched += pulse.Schedule(old)
sched = sched.flatten()
sched = sched.replace(old, new)
assert sched == pulse.Schedule(new)
Parameters
- old (
ScheduleComponent
) – Instruction to replace. - new (
ScheduleComponent
) – Instruction to replace with. - inplace (
bool
) – Replace instruction by mutably modifying thisSchedule
.
Return type
Schedule
Returns
The modified schedule with old
replaced by new
.
Raises
PulseError – If the Schedule
after replacements will has a timing overlap.
shift
shift(time, name=None, inplace=False)
Return a schedule shifted forward by time
.
Parameters
- time (
int
) – Time to shift by. - name (
Optional
[str
]) – Name of the new schedule. Defaults to the name of self. - inplace (
bool
) – Perform operation inplace on this schedule. Otherwise return a newSchedule
.
Return type
Schedule
start_time
Starting time of this schedule component.
Return type
int
stop_time
Stopping time of this schedule component.
Return type
int