Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/apidoc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ API Reference
primitives
qasm2
qasm3
qasm
qobj
qpy
quantum_info
Expand Down
6 changes: 0 additions & 6 deletions docs/apidoc/qasm.rst

This file was deleted.

5 changes: 0 additions & 5 deletions qiskit/circuit/library/blueprintcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@ def parameters(self) -> ParameterView:
self._build()
return super().parameters

def qasm(self, formatted=False, filename=None, encoding=None):
if not self._is_built:
self._build()
return super().qasm(formatted, filename, encoding)

def _append(self, instruction, _qargs=None, _cargs=None):
if not self._is_built:
self._build()
Expand Down
60 changes: 0 additions & 60 deletions qiskit/circuit/quantumcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
from qiskit.circuit.gate import Gate
from qiskit.circuit.parameter import Parameter
from qiskit.circuit.exceptions import CircuitError
from qiskit.utils import optionals as _optionals
from qiskit.utils.deprecation import deprecate_func
from . import _classical_resource_map
from ._utils import sort_parameters
Expand Down Expand Up @@ -1619,65 +1618,6 @@ def decompose(
# do not copy operations, this is done in the conversion with circuit_to_dag
return dag_to_circuit(dag, copy_operations=False)

def qasm(
self,
formatted: bool = False,
filename: str | None = None,
encoding: str | None = None,
) -> str | None:
Comment on lines -1622 to -1627
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to remember to follow up this removal with a 0.46 deprecation if we're going ahead with it for 1.0 (which I think we should).

"""Return OpenQASM 2.0 string.

.. seealso::

:func:`.qasm2.dump` and :func:`.qasm2.dumps`
The preferred entry points to the OpenQASM 2 export capabilities. These match the
interface for other serialisers in Qiskit.

Args:
formatted (bool): Return formatted OpenQASM 2.0 string.
filename (str): Save OpenQASM 2.0 to file with name 'filename'.
encoding (str): Optionally specify the encoding to use for the
output file if ``filename`` is specified. By default this is
set to the system's default encoding (ie whatever
``locale.getpreferredencoding()`` returns) and can be set to
any valid codec or alias from stdlib's
`codec module <https://docs.python.org/3/library/codecs.html#standard-encodings>`__

Returns:
str: If formatted=False.

Raises:
MissingOptionalLibraryError: If pygments is not installed and ``formatted`` is
``True``.
QASM2ExportError: If circuit has free parameters.
QASM2ExportError: If an operation that has no OpenQASM 2 representation is encountered.
"""
from qiskit import qasm2 # pylint: disable=cyclic-import

out = qasm2.dumps(self)
if filename is not None:
with open(filename, "w+", encoding=encoding) as file:
print(out, file=file)

if formatted:
_optionals.HAS_PYGMENTS.require_now("formatted OpenQASM 2.0 output")

import pygments
from pygments.formatters import ( # pylint: disable=no-name-in-module
Terminal256Formatter,
)
from qiskit.qasm.pygments import OpenQASMLexer
from qiskit.qasm.pygments import QasmTerminalStyle

code = pygments.highlight(
out, OpenQASMLexer(), Terminal256Formatter(style=QasmTerminalStyle)
)
print(code)
return None
# The old `QuantumCircuit.qasm()` method included a terminating new line that `qasm2.dumps`
# doesn't, so for full compatibility we add it back here.
return out + "\n"

def draw(
self,
output: str | None = None,
Expand Down
2 changes: 0 additions & 2 deletions qiskit/converters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
.. autofunction:: dag_to_circuit
.. autofunction:: circuit_to_instruction
.. autofunction:: circuit_to_gate
.. autofunction:: ast_to_dag
.. autofunction:: dagdependency_to_circuit
.. autofunction:: circuit_to_dagdependency
.. autofunction:: dag_to_dagdependency
Expand All @@ -32,7 +31,6 @@
from .dag_to_circuit import dag_to_circuit
from .circuit_to_instruction import circuit_to_instruction
from .circuit_to_gate import circuit_to_gate
from .ast_to_dag import ast_to_dag
from .circuit_to_dagdependency import circuit_to_dagdependency
from .dagdependency_to_circuit import dagdependency_to_circuit
from .dag_to_dagdependency import dag_to_dagdependency
Expand Down
Loading