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.
Attributes
channels
Type: Tuple[qiskit.pulse.channels.Channel]
Returns channels that this schedule uses.
Return type
Tuple
[Channel
]
duration
Type: int
Duration of this schedule component.
Return type
int
instances_counter
Default value: count(0)
instructions
name
Type: str
Name of ScheduleComponent.
Return type
str
prefix
Default value: 'sched'
start_time
Type: int
Starting time of this schedule component.
Return type
int
stop_time
Type: int
Stopping time of this schedule component.
Return type
int
timeslots
Type: Dict[qiskit.pulse.channels.Channel, List[Tuple[int, int]]]
Time keeping attribute.
Return type
Dict
[Channel
, List
[Tuple
[int
, int
]]]
Methods
append
Schedule.append(schedule, name=None)
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
.
Return type
ch_duration
Schedule.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
Schedule.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
Schedule.ch_stop_time(*channels)
Return maximum start time over supplied channels.
Parameters
*channels – Channels within self
to include.
Return type
int
draw
Schedule.draw(dt=1, style=None, filename=None, interp_method=None, scale=None, channel_scales=None, channels_to_plot=None, plot_all=False, plot_range=None, interactive=False, table=True, label=False, framechange=True, scaling=None, 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. - channels_to_plot (
Optional
[List
[Channel
]]) – Deprecated, seechannels
. - 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. - scaling (
Optional
[float
]) – Deprecated, seescale
. - channels (
Optional
[List
[Channel
]]) – A list of channel names 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
exclude
Schedule.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
filter
Schedule.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
flatten
Schedule.flatten()
Return a new schedule which is the flattened schedule contained all instructions
.
Return type
insert
Schedule.insert(start_time, schedule, name=None)
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.
Return type
shift
Schedule.shift(time, name=None)
Return a new 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.
Return type
union
Schedule.union(*schedules, name=None)
Return a new schedule which is the union of both self
and schedules
.
Parameters
- *schedules – Schedules to be take the union with this
Schedule
. - name (
Optional
[str
]) – Name of the new schedule. Defaults to the name of self.
Return type