def test_schedule_matplotlib_drawer(self): filename = self._get_resource_path( 'current_schedule_matplotlib_ref.png') schedule = self.sample_schedule() pulse_drawer(schedule, filename=filename) self.assertImagesAreEqual(filename, self.schedule_matplotlib_reference) os.remove(filename)
def test_instruction_matplotlib_drawer(self): filename = self._get_resource_path( 'current_instruction_matplotlib_ref.png') pulse_instruction = self.sample_instruction() pulse_drawer(pulse_instruction, filename=filename) self.assertImagesAreEqual(filename, self.instr_matplotlib_reference) os.remove(filename)
def test_parametric_pulse_schedule(self): """Test that parametric instructions/schedules can be drawn.""" filename = self._get_resource_path( 'current_schedule_matplotlib_ref.png') schedule = Schedule(name='test_parametric') schedule += Gaussian(duration=25, sigma=4, amp=0.5j)(DriveChannel(0)) pulse_drawer(schedule, filename=filename) self.assertImagesAreEqual(filename, self.parametric_matplotlib_reference) os.remove(filename)
def test_schedule_drawer_show_framechange(self): filename = self._get_resource_path('current_show_framechange_ref.png') gp0 = pulse_lib.gaussian(duration=20, amp=1.0, sigma=1.0) sched = Schedule() sched = sched.append(gp0(DriveChannel(0))) sched = sched.insert(60, FrameChange(phase=-1.57)(DriveChannel(0))) sched = sched.insert(30, FrameChange(phase=-1.50)(DriveChannel(1))) sched = sched.insert(70, FrameChange(phase=1.50)(DriveChannel(1))) pulse_drawer(sched, filename=filename, show_framechange_channels=False) self.assertImagesAreEqual(filename, self.schedule_show_framechange_ref) os.remove(filename)
def draw(self, dt: float = 1, style=None, filename: str = None, interp_method: Callable = None, scaling: float = 1, interactive: bool = False): """Plot the interpolated envelope of pulse. Args: dt: Time interval of samples. style (OPStylePulse): A style sheet to configure plot appearance filename: Name required to save pulse image interp_method: A function for interpolation scaling (float): Relative visual scaling of waveform amplitudes interactive: When set true show the circuit in a new window (this depends on the matplotlib backend being used supporting this) Returns: matplotlib.figure: A matplotlib figure object of the pulse envelope. """ # pylint: disable=invalid-name, cyclic-import from qiskit.tools import visualization return visualization.pulse_drawer(self, dt=dt, style=style, filename=filename, interp_method=interp_method, scaling=scaling, interactive=interactive)
def draw(self, dt: float = 1, style=None, filename: str = None, interp_method: Callable = None, scaling: float = 1, channels_to_plot: List[Channel] = None, plot_all: bool = False, plot_range: Tuple[float] = None, interactive: bool = False, table: bool = True, label: bool = False, framechange: bool = True): """Plot the instruction. Args: dt: Time interval of samples style (OPStyleSched): A style sheet to configure plot appearance filename: Name required to save pulse image interp_method: A function for interpolation scaling (float): Relative visual scaling of waveform amplitudes channels_to_plot: A list of channel names to plot plot_all: Plot empty channels plot_range: A tuple of time range to plot interactive: When set true show the circuit in a new window (this depends on the matplotlib backend being used supporting this) table: Draw event table for supported commands label: Label individual instructions framechange: Add framechange indicators Returns: matplotlib.figure: A matplotlib figure object of the pulse schedule. """ # pylint: disable=invalid-name, cyclic-import from qiskit.tools import visualization return visualization.pulse_drawer(self, dt=dt, style=style, filename=filename, interp_method=interp_method, scaling=scaling, channels_to_plot=channels_to_plot, plot_all=plot_all, plot_range=plot_range, interactive=interactive, table=table, label=label, framechange=framechange)
def draw(self, **kwargs): """Plot the interpolated envelope of pulse. Keyword Args: dt (float): Time interval of samples. interp_method (str): Method of interpolation (set `None` for turn off the interpolation). filename (str): Name required to save pulse image. interactive (bool): When set true show the circuit in a new window (this depends on the matplotlib backend being used supporting this). dpi (int): Resolution of saved image. nop (int): Data points for interpolation. size (tuple): Size of figure. """ from qiskit.tools.visualization import pulse_drawer return pulse_drawer(self.samples, self.duration, **kwargs)