コード例 #1
0
    def draw(
        self,
        style: Optional[Dict[str, Any]] = None,
        backend=None,  # importing backend causes cyclic import
        time_range: Optional[Tuple[int, int]] = None,
        time_unit: str = "dt",
        show_waveform_info: bool = True,
        plotter: str = "mpl2d",
        axis: Optional[Any] = None,
    ):
        """Plot the interpolated envelope of pulse.

        Args:
            style: Stylesheet options. This can be dictionary or preset stylesheet classes. See
                :py:class:`~qiskit.visualization.pulse_v2.stylesheets.IQXStandard`,
                :py:class:`~qiskit.visualization.pulse_v2.stylesheets.IQXSimple`, and
                :py:class:`~qiskit.visualization.pulse_v2.stylesheets.IQXDebugging` for details of
                preset stylesheets.
            backend (Optional[BaseBackend]): Backend object to play the input pulse program.
                If provided, the plotter may use to make the visualization hardware aware.
            time_range: Set horizontal axis limit. Tuple ``(tmin, tmax)``.
            time_unit: The unit of specified time range either ``dt`` or ``ns``.
                The unit of ``ns`` is available only when ``backend`` object is provided.
            show_waveform_info: Show waveform annotations, i.e. name, of waveforms.
                Set ``True`` to show additional information about waveforms.
            plotter: Name of plotter API to generate an output image.
                One of following APIs should be specified::

                    mpl2d: Matplotlib API for 2D image generation.
                        Matplotlib API to generate 2D image. Charts are placed along y axis with
                        vertical offset. This API takes matplotlib.axes.Axes as `axis` input.

                `axis` and `style` kwargs may depend on the plotter.
            axis: Arbitrary object passed to the plotter. If this object is provided,
                the plotters use a given ``axis`` instead of internally initializing
                a figure object. This object format depends on the plotter.
                See plotter argument for details.

        Returns:
            Visualization output data.
            The returned data type depends on the ``plotter``.
            If matplotlib family is specified, this will be a ``matplotlib.pyplot.Figure`` data.
        """
        # pylint: disable=cyclic-import, missing-return-type-doc
        from qiskit.visualization import pulse_drawer_v2

        return pulse_drawer_v2(
            program=self,
            style=style,
            backend=backend,
            time_range=time_range,
            time_unit=time_unit,
            show_waveform_info=show_waveform_info,
            plotter=plotter,
            axis=axis,
        )
コード例 #2
0
    def draw(
        self,
        dt: Any = None,  # deprecated
        style: Optional[Dict[str, Any]] = None,
        filename: Any = None,  # deprecated
        interp_method: Any = None,  # deprecated
        scale: Any = None,  # deprecated
        interactive: Any = None,  # deprecated
        draw_title: Any = None,  # deprecated
        backend=None,  # importing backend causes cyclic import
        time_range: Optional[Tuple[int, int]] = None,
        time_unit: str = "dt",
        show_waveform_info: bool = True,
        plotter: str = "mpl2d",
        axis: Optional[Any] = None,
    ):
        """Plot the interpolated envelope of pulse.

        Args:
            style: Stylesheet options. This can be dictionary or preset stylesheet classes. See
                :py:class:~`qiskit.visualization.pulse_v2.stylesheets.IQXStandard`,
                :py:class:~`qiskit.visualization.pulse_v2.stylesheets.IQXSimple`, and
                :py:class:~`qiskit.visualization.pulse_v2.stylesheets.IQXDebugging` for details of
                preset stylesheets.
            backend (Optional[BaseBackend]): Backend object to play the input pulse program.
                If provided, the plotter may use to make the visualization hardware aware.
            time_range: Set horizontal axis limit. Tuple ``(tmin, tmax)``.
            time_unit: The unit of specified time range either ``dt`` or ``ns``.
                The unit of ``ns`` is available only when ``backend`` object is provided.
            show_waveform_info: Show waveform annotations, i.e. name, of waveforms.
                Set ``True`` to show additional information about waveforms.
            plotter: Name of plotter API to generate an output image.
                One of following APIs should be specified::

                    mpl2d: Matplotlib API for 2D image generation.
                        Matplotlib API to generate 2D image. Charts are placed along y axis with
                        vertical offset. This API takes matplotlib.axes.Axes as `axis` input.

                `axis` and `style` kwargs may depend on the plotter.
            axis: Arbitrary object passed to the plotter. If this object is provided,
                the plotters use a given ``axis`` instead of internally initializing
                a figure object. This object format depends on the plotter.
                See plotter argument for details.
            dt: Deprecated. This argument is used by the legacy pulse drawer.
            filename: Deprecated. This argument is used by the legacy pulse drawer.
                To save output image, you can call `.savefig` method with
                returned Matplotlib Figure object.
            interp_method: Deprecated. This argument is used by the legacy pulse drawer.
            scale: Deprecated. This argument is used by the legacy pulse drawer.
            interactive: Deprecated. This argument is used by the legacy pulse drawer.
            draw_title: Deprecated. This argument is used by the legacy pulse drawer.

        Returns:
            Visualization output data.
            The returned data type depends on the ``plotter``.
            If matplotlib family is specified, this will be a ``matplotlib.pyplot.Figure`` data.
        """
        # pylint: disable=cyclic-import, missing-return-type-doc
        from qiskit.visualization import pulse_drawer_v2, PulseStyle

        legacy_args = {
            "dt": dt,
            "filename": filename,
            "interp_method": interp_method,
            "scale": scale,
            "interactive": interactive,
            "draw_title": draw_title,
        }

        active_legacy_args = []
        for name, legacy_arg in legacy_args.items():
            if legacy_arg is not None:
                active_legacy_args.append(name)

        if active_legacy_args:
            warnings.warn(
                "Legacy pulse drawer is deprecated. "
                "Specified arguments {dep_args} are deprecated. "
                "Please check the API document of new pulse drawer "
                "`qiskit.visualization.pulse_drawer_v2`."
                "".format(dep_args=", ".join(active_legacy_args)),
                DeprecationWarning,
            )

        if filename:
            warnings.warn(
                "File saving is delegated to the plotter software in new drawer. "
                "If you specify matplotlib plotter family to `plotter` argument, "
                "you can call `savefig` method with the returned Figure object.",
                DeprecationWarning,
            )

        if isinstance(style, PulseStyle):
            style = None
            warnings.warn(
                "Legacy stylesheet is specified. This is ignored in the new drawer. "
                "Please check the API documentation for this method.")

        return pulse_drawer_v2(
            program=self,
            style=style,
            backend=backend,
            time_range=time_range,
            time_unit=time_unit,
            show_waveform_info=show_waveform_info,
            plotter=plotter,
            axis=axis,
        )
コード例 #3
0
    def draw(
            self,
            dt: Any = None,  # deprecated
            style: Optional[Dict[str, Any]] = None,
            filename: Any = None,  # deprecated
            interp_method: Any = None,  # deprecated
            scale: Any = None,  # deprecated
            channel_scales: Any = None,  # deprecated
            plot_all: Any = None,  # deprecated
            plot_range: Any = None,  # deprecated
            interactive: Any = None,  # deprecated
            table: Any = None,  # deprecated
            label: Any = None,  # deprecated
            framechange: Any = None,  # deprecated
            channels: Any = None,  # deprecated
            show_framechange_channels: Any = None,  # deprecated
            draw_title: Any = None,  # deprecated
            backend=None,  # importing backend causes cyclic import
            time_range: Optional[Tuple[int, int]] = None,
            time_unit: str = 'dt',
            disable_channels: Optional[List[Channel]] = None,
            show_snapshot: bool = True,
            show_framechange: bool = True,
            show_waveform_info: bool = True,
            show_barrier: bool = True,
            plotter: str = 'mpl2d',
            axis: Optional[Any] = None):
        """Plot the schedule.

        Args:
            style: Stylesheet options. This can be dictionary or preset stylesheet classes. See
                :py:class:~`qiskit.visualization.pulse_v2.stylesheets.IQXStandard`,
                :py:class:~`qiskit.visualization.pulse_v2.stylesheets.IQXSimple`, and
                :py:class:~`qiskit.visualization.pulse_v2.stylesheets.IQXDebugging` for details of
                preset stylesheets.
            backend (Optional[BaseBackend]): Backend object to play the input pulse program.
                If provided, the plotter may use to make the visualization hardware aware.
            time_range: Set horizontal axis limit. Tuple `(tmin, tmax)`.
            time_unit: The unit of specified time range either `dt` or `ns`.
                The unit of `ns` is available only when `backend` object is provided.
            disable_channels: A control property to show specific pulse channel.
                Pulse channel instances provided as a list are not shown in the output image.
            show_snapshot: Show snapshot instructions.
            show_framechange: Show frame change instructions. The frame change represents
                instructions that modulate phase or frequency of pulse channels.
            show_waveform_info: Show additional information about waveforms such as their name.
            show_barrier: Show barrier lines.
            plotter: Name of plotter API to generate an output image.
                One of following APIs should be specified::

                    mpl2d: Matplotlib API for 2D image generation.
                        Matplotlib API to generate 2D image. Charts are placed along y axis with
                        vertical offset. This API takes matplotlib.axes.Axes as ``axis`` input.

                ``axis`` and ``style`` kwargs may depend on the plotter.
            axis: Arbitrary object passed to the plotter. If this object is provided,
                the plotters use a given ``axis`` instead of internally initializing
                a figure object. This object format depends on the plotter.
                See plotter argument for details.
            dt: Deprecated. This argument is used by the legacy pulse drawer.
            filename: Deprecated. This argument is used by the legacy pulse drawer.
                To save output image, you can call ``.savefig`` method with
                returned Matplotlib Figure object.
            interp_method: Deprecated. This argument is used by the legacy pulse drawer.
            scale: Deprecated. This argument is used by the legacy pulse drawer.
            channel_scales: Deprecated. This argument is used by the legacy pulse drawer.
            plot_all: Deprecated. This argument is used by the legacy pulse drawer.
            plot_range: Deprecated. This argument is used by the legacy pulse drawer.
            interactive: Deprecated. This argument is used by the legacy pulse drawer.
            table: Deprecated. This argument is used by the legacy pulse drawer.
            label: Deprecated. This argument is used by the legacy pulse drawer.
            framechange: Deprecated. This argument is used by the legacy pulse drawer.
            channels: Deprecated. This argument is used by the legacy pulse drawer.
            show_framechange_channels: Deprecated. This argument is used by the legacy pulse drawer.
            draw_title: Deprecated. This argument is used by the legacy pulse drawer.

        Returns:
            Visualization output data.
            The returned data type depends on the ``plotter``.
            If matplotlib family is specified, this will be a ``matplotlib.pyplot.Figure`` data.
        """
        # pylint: disable=invalid-name, cyclic-import, missing-return-type-doc
        from qiskit.visualization import pulse_drawer_v2, SchedStyle

        legacy_args = {
            'dt': dt,
            'filename': filename,
            'interp_method': interp_method,
            'scale': scale,
            'channel_scales': channel_scales,
            'plot_all': plot_all,
            'plot_range': plot_range,
            'interactive': interactive,
            'table': table,
            'label': label,
            'framechange': framechange,
            'channels': channels,
            'show_framechange_channels': show_framechange_channels,
            'draw_title': draw_title
        }

        active_legacy_args = []
        for name, legacy_arg in legacy_args.items():
            if legacy_arg is not None:
                active_legacy_args.append(name)

        if active_legacy_args:
            warnings.warn(
                'Legacy pulse drawer is deprecated. '
                'Specified arguments {dep_args} are deprecated. '
                'Please check the API document of new pulse drawer '
                '`qiskit.visualization.pulse_drawer_v2`.'
                ''.format(dep_args=', '.join(active_legacy_args)),
                DeprecationWarning)

        if filename:
            warnings.warn(
                'File saving is delegated to the plotter software in new drawer. '
                'If you specify matplotlib plotter family to `plotter` argument, '
                'you can call `savefig` method with the returned Figure object.',
                DeprecationWarning)

        if isinstance(style, SchedStyle):
            style = None
            warnings.warn(
                'Legacy stylesheet is specified. This is ignored in the new drawer. '
                'Please check the API documentation for this method.')

        return pulse_drawer_v2(program=self,
                               style=style,
                               backend=backend,
                               time_range=time_range,
                               time_unit=time_unit,
                               disable_channels=disable_channels,
                               show_snapshot=show_snapshot,
                               show_framechange=show_framechange,
                               show_waveform_info=show_waveform_info,
                               show_barrier=show_barrier,
                               plotter=plotter,
                               axis=axis)