Skip to content

Commit

Permalink
Merge branch 'remove-opflow' of https://github.com/ElePT/qiskit-terra
Browse files Browse the repository at this point in the history
…into remove-opflow
  • Loading branch information
ElePT committed Oct 25, 2023
2 parents 6b23a32 + 17f16dd commit 07529f1
Show file tree
Hide file tree
Showing 30 changed files with 778 additions and 62 deletions.
44 changes: 38 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/accelerate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ numpy = "0.19.0"
rand = "0.8"
rand_pcg = "0.3"
rand_distr = "0.4.3"
ahash = "0.8.3"
ahash = "0.8.6"
num-complex = "0.4"
num-bigint = "0.4"
rustworkx-core = "0.13"
Expand Down
24 changes: 12 additions & 12 deletions docs/legacy_release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ Transpiler Features

- A new method :meth:`~qiskit.dagcircuit.DAGCircuit.find_bit` has
been added to the :class:`~qiskit.dagcircuit.DAGCircuit` class,
which returns the bit locations of the given :class:`.Qubit` or
which returns the bit locations of the given :class:`~.circuit.Qubit` or
:class:`.Clbit` as a tuple of the positional index of the bit within
the circuit and a list of tuples which locate the bit in the circuit's
registers.
Expand Down Expand Up @@ -1597,7 +1597,7 @@ Bug Fixes
.. releasenotes/notes/fix-bit-copy-4b2f7349683f616a.yaml @ b'163d1bd7835d58eaf8842c594b3696fb99c8442f'

- Fixed an issue with copying circuits with new-style :class:`.Clbit`\ s and
:class:`.Qubit`\ s (bits without registers) where references to these bits
:class:`~.circuit.Qubit`\ s (bits without registers) where references to these bits
from the containing circuit could be broken, causing issues with
serialization and circuit visualization.
Fixed `#10409 <https://github.com/Qiskit/qiskit-terra/issues/10409>`__
Expand Down Expand Up @@ -4326,8 +4326,8 @@ Bug Fixes

.. releasenotes/notes/fix-deprecated-bit-qpy-roundtrip-9a23a795aa677c71.yaml @ b'3dbbb32e762850db265c7bb40787a36351aad917'

- The deprecated :class:`.Qubit` and :class:`.Clbit` properties :attr:`~.Qubit.register` and
:attr:`~.Qubit.index` will now be correctly round-tripped by QPY (:mod:`qiskit.qpy`) in all
- The deprecated :class:`~.circuit.Qubit` and :class:`.Clbit` properties :attr:`~.circuit.Qubit.register` and
:attr:`~.circuit.Qubit.index` will now be correctly round-tripped by QPY (:mod:`qiskit.qpy`) in all
valid usages of :class:`.QuantumRegister` and :class:`.ClassicalRegister`. In earlier releases
in the Terra 0.23 series, this information would be lost. In versions before 0.23.0, this
information was partially reconstructed but could be incorrect or produce invalid circuits for
Expand Down Expand Up @@ -7031,7 +7031,7 @@ Bug Fixes

- QPY deserialisation will no longer add extra :class:`.Clbit` instances to the
circuit if there are both loose :class:`.Clbit`\ s in the circuit and more
:class:`.Qubit`\ s than :class:`.Clbit`\ s.
:class:`~.circuit.Qubit`\ s than :class:`.Clbit`\ s.

.. releasenotes/notes/fix-qpy-loose-bits-5283dc4ad3823ce3.yaml @ b'e0befd769fc54e9f50cdc4b355983b9d1eda6f31'

Expand Down Expand Up @@ -9062,7 +9062,7 @@ Bug Fixes
.. releasenotes/notes/0.22/denselayout-loose-bits-3e66011432bc6232.yaml @ b'618770367f7a5a3a22fd43ea9fcfb7f17393eb6a'

- Fixed an issue in the :class:`~.DenseLayout` transpiler pass where any
loose :class:`~.Qubit` objects (i.e. not part of a :class:`~.QuantumRegister`)
loose :class:`~.circuit.Qubit` objects (i.e. not part of a :class:`~.QuantumRegister`)
that were part of a :class:`~.QuantumCircuit` would not be included in the
output :class:`~.Layout` that was generated by the pass.

Expand All @@ -9071,7 +9071,7 @@ Bug Fixes
- The :meth:`.Operator.from_circuit` constructor method has been updated
so that it can handle the layout output from :func:`~.transpile` and
correctly reverse the qubit permutation caused by layout in all cases.
Previously, if your transpiled circuit used loose :class:`~.Qubit` objects,
Previously, if your transpiled circuit used loose :class:`~.circuit.Qubit` objects,
multiple :class:`~.QuantumRegister` objects, or a single
:class:`~.QuantumRegister` with a name other than ``"q"`` the constructor
would have failed to create an :class:`~.Operator` from the circuit.
Expand Down Expand Up @@ -10274,7 +10274,7 @@ Upgrade Notes

- The data type of each element in :attr:`.QuantumCircuit.data` has changed.
It used to be a simple 3-tuple of an :class:`~.circuit.Instruction`, a list
of :class:`.Qubit`\ s, and a list of :class:`.Clbit`\ s, whereas it is now
of :class:`~.circuit.Qubit`\ s, and a list of :class:`.Clbit`\ s, whereas it is now
an instance of :class:`.CircuitInstruction`.

The attributes of this new class are :attr:`~.CircuitInstruction.operation`,
Expand Down Expand Up @@ -10651,7 +10651,7 @@ Bug Fixes
.. releasenotes/notes/0.21/fix-reverse_bits-with-registerless-bits-6d17597b99640fb0.yaml @ b'0f377f7a2cdbd7eaa46e8e2b5de974c8c22b9612'

- Fixed :meth:`.QuantumCircuit.reverse_bits` with circuits containing registerless
:class:`.Qubit` and :class:`.Clbit`. For example, the following will now work::
:class:`~.circuit.Qubit` and :class:`.Clbit`. For example, the following will now work::

from qiskit.circuit import QuantumCircuit, Qubit, Clbit

Expand Down Expand Up @@ -10954,7 +10954,7 @@ Bug Fixes
- Fixed an issue with the visualization function :func:`~.dag_drawer` and
method :meth:`.DAGCircuit.draw` where previously the drawer would fail
when attempting to generate a visualization for a :class:`~.DAGCircuit`
object that contained a :class:`~.Qubit` or :class:`~.Clbit` which wasn't
object that contained a :class:`~.circuit.Qubit` or :class:`~.Clbit` which wasn't
part of a :class:`~QuantumRegister` or :class:`~ClassicalRegister`.
Fixed `#7915 <https://github.com/Qiskit/qiskit-terra/issues/7915>`__.

Expand Down Expand Up @@ -12350,7 +12350,7 @@ Upgrade Notes

.. releasenotes/notes/0.20/bit-slots-17d6649872da0440.yaml @ b'a2d13f55aad6c670f71a4613516b8891e02ece63'

- The classes :class:`.Qubit`, :class:`.Clbit` and :class:`.AncillaQubit` now
- The classes :class:`~.circuit.Qubit`, :class:`.Clbit` and :class:`.AncillaQubit` now
have the ``__slots__`` attribute. This is to reduce their memory usage. As a
side effect, they can no longer have arbitrary data attached as attributes
to them. This is very unlikely to have any effect on downstream code other
Expand Down Expand Up @@ -13180,7 +13180,7 @@ Bug Fixes
- Fixed QPY serialization of :class:`.QuantumCircuit` containing subsets of
bits from a :class:`.QuantumRegister` or :class:`.ClassicalRegister`.
Previously if you tried to serialize a circuit like this it would
incorrectly treat these bits as standalone :class:`.Qubit` or
incorrectly treat these bits as standalone :class:`~.circuit.Qubit` or
:class:`.Clbit` without having a register set. For example, if you try to
serialize a circuit like::

Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/bit.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Bit:
.. note::
This class should not be instantiated directly. This is just a superclass
for :class:`~.Clbit` and :class:`~.Qubit`.
for :class:`~.Clbit` and :class:`~.circuit.Qubit`.
"""

Expand Down
8 changes: 4 additions & 4 deletions qiskit/circuit/library/generalized_gates/mcmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from collections.abc import Callable

from qiskit import circuit
from qiskit.circuit import ControlledGate, Gate, Qubit, QuantumRegister, QuantumCircuit
from qiskit.circuit import ControlledGate, Gate, QuantumRegister, QuantumCircuit
from qiskit.exceptions import QiskitError

# pylint: disable=cyclic-import
Expand Down Expand Up @@ -51,7 +51,7 @@ class MCMT(QuantumCircuit):

def __init__(
self,
gate: Gate | Callable[[QuantumCircuit, Qubit, Qubit], circuit.Instruction],
gate: Gate | Callable[[QuantumCircuit, circuit.Qubit, circuit.Qubit], circuit.Instruction],
num_ctrl_qubits: int,
num_target_qubits: int,
) -> None:
Expand Down Expand Up @@ -214,8 +214,8 @@ def num_ancilla_qubits(self):

def _ccx_v_chain_rule(
self,
control_qubits: QuantumRegister | list[Qubit],
ancilla_qubits: QuantumRegister | list[Qubit],
control_qubits: QuantumRegister | list[circuit.Qubit],
ancilla_qubits: QuantumRegister | list[circuit.Qubit],
reverse: bool = False,
) -> None:
"""Get the rule for the CCX V-chain.
Expand Down
6 changes: 3 additions & 3 deletions qiskit/circuit/quantumcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ def data(self, data_input: Iterable):
elements must either be instances of :class:`.CircuitInstruction` (preferred), or a
3-tuple of ``(instruction, qargs, cargs)`` (legacy). In the legacy format,
``instruction`` must be an :class:`~.circuit.Instruction`, while ``qargs`` and
``cargs`` must be iterables of :class:`.Qubit` or :class:`.Clbit` specifiers
(similar to the allowed forms in calls to :meth:`append`).
``cargs`` must be iterables of :class:`~.circuit.Qubit` or :class:`.Clbit`
specifiers (similar to the allowed forms in calls to :meth:`append`).
"""
# If data_input is QuantumCircuitData(self), clearing self._data
# below will also empty data_input, so make a shallow copy first.
Expand Down Expand Up @@ -1230,7 +1230,7 @@ def append(
Args:
instruction: :class:`~.circuit.Instruction` instance to append, or a
:class:`.CircuitInstruction` with all its context.
qargs: specifiers of the :class:`.Qubit`\\ s to attach instruction to.
qargs: specifiers of the :class:`~.circuit.Qubit`\\ s to attach instruction to.
cargs: specifiers of the :class:`.Clbit`\\ s to attach instruction to.
Returns:
Expand Down
4 changes: 2 additions & 2 deletions qiskit/converters/circuit_to_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def circuit_to_dag(circuit, copy_operations=True, *, qubit_order=None, clbit_ord
:class:`~.DAGCircuit` will be shared instances and modifications to
operations in the :class:`~.DAGCircuit` will be reflected in the
:class:`~.QuantumCircuit` (and vice versa).
qubit_order (Iterable[Qubit] or None): the order that the qubits should be indexed in the
output DAG. Defaults to the same order as in the circuit.
qubit_order (Iterable[~qiskit.circuit.Qubit] or None): the order that the qubits should be
indexed in the output DAG. Defaults to the same order as in the circuit.
clbit_order (Iterable[Clbit] or None): the order that the clbits should be indexed in the
output DAG. Defaults to the same order as in the circuit.
Expand Down
18 changes: 9 additions & 9 deletions qiskit/dagcircuit/dagcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,10 @@ def remove_qubits(self, *qubits):
also be removed.
Args:
qubits (List[Qubit]): The bits to remove.
qubits (List[~qiskit.circuit.Qubit]): The bits to remove.
Raises:
DAGCircuitError: a qubit is not a :obj:`.Qubit`, is not in the circuit,
DAGCircuitError: a qubit is not a :obj:`~.circuit.Qubit`, is not in the circuit,
or is not idle.
"""
if any(not isinstance(qubit, Qubit) for qubit in qubits):
Expand Down Expand Up @@ -643,11 +643,11 @@ def apply_operation_back(self, op, qargs=(), cargs=(), *, check=True):
Args:
op (qiskit.circuit.Operation): the operation associated with the DAG node
qargs (tuple[Qubit]): qubits that op will be applied to
qargs (tuple[~qiskit.circuit.Qubit]): qubits that op will be applied to
cargs (tuple[Clbit]): cbits that op will be applied to
check (bool): If ``True`` (default), this function will enforce that the
:class:`.DAGCircuit` data-structure invariants are maintained (all ``qargs`` are
:class:`.Qubit`\\ s, all are in the DAG, etc). If ``False``, the caller *must*
:class:`~.circuit.Qubit`\\ s, all are in the DAG, etc). If ``False``, the caller *must*
uphold these invariants itself, but the cost of several checks will be skipped.
This is most useful when building a new DAG from a source of known-good nodes.
Returns:
Expand Down Expand Up @@ -697,11 +697,11 @@ def apply_operation_front(self, op, qargs=(), cargs=(), *, check=True):
Args:
op (qiskit.circuit.Operation): the operation associated with the DAG node
qargs (tuple[Qubit]): qubits that op will be applied to
qargs (tuple[~qiskit.circuit.Qubit]): qubits that op will be applied to
cargs (tuple[Clbit]): cbits that op will be applied to
check (bool): If ``True`` (default), this function will enforce that the
:class:`.DAGCircuit` data-structure invariants are maintained (all ``qargs`` are
:class:`.Qubit`\\ s, all are in the DAG, etc). If ``False``, the caller *must*
:class:`~.circuit.Qubit`\\ s, all are in the DAG, etc). If ``False``, the caller *must*
uphold these invariants itself, but the cost of several checks will be skipped.
This is most useful when building a new DAG from a source of known-good nodes.
Returns:
Expand Down Expand Up @@ -755,7 +755,7 @@ def compose(self, other, qubits=None, clbits=None, front=False, inplace=True):
Args:
other (DAGCircuit): circuit to compose with self
qubits (list[Qubit|int]): qubits of self to compose onto.
qubits (list[~qiskit.circuit.Qubit|int]): qubits of self to compose onto.
clbits (list[Clbit|int]): clbits of self to compose onto.
front (bool): If True, front composition will be performed (not implemented yet)
inplace (bool): If True, modify the object. Otherwise return composed circuit.
Expand Down Expand Up @@ -2042,10 +2042,10 @@ def quantum_causal_cone(self, qubit):
classical bit wires are ignored for the purposes of building the causal cone.
Args:
qubit (Qubit): The output qubit for which we want to find the causal cone.
qubit (~qiskit.circuit.Qubit): The output qubit for which we want to find the causal cone.
Returns:
Set[Qubit]: The set of qubits whose interactions affect ``qubit``.
Set[~qiskit.circuit.Qubit]: The set of qubits whose interactions affect ``qubit``.
"""
# Retrieve the output node from the qubit
output_node = self.output_map.get(qubit, None)
Expand Down
6 changes: 3 additions & 3 deletions qiskit/dagcircuit/dagdependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def _create_op_node(self, operation, qargs, cargs):
Args:
operation (qiskit.circuit.Operation): operation
qargs (list[Qubit]): list of qubits on which the operation acts
qargs (list[~qiskit.circuit.Qubit]): list of qubits on which the operation acts
cargs (list[Clbit]): list of classical wires to attach to
Returns:
Expand Down Expand Up @@ -421,7 +421,7 @@ def add_op_node(self, operation, qargs, cargs):
Args:
operation (qiskit.circuit.Operation): operation as a quantum gate
qargs (list[Qubit]): list of qubits on which the operation acts
qargs (list[~qiskit.circuit.Qubit]): list of qubits on which the operation acts
cargs (list[Clbit]): list of classical wires to attach to
"""
new_node = self._create_op_node(operation, qargs, cargs)
Expand Down Expand Up @@ -561,7 +561,7 @@ def replace_block_with_op(self, node_block, op, wire_pos_map, cycle_check=True):
node block to be replaced
op (qiskit.circuit.Operation): The operation to replace the
block with
wire_pos_map (Dict[Qubit, int]): The dictionary mapping the qarg to
wire_pos_map (Dict[~qiskit.circuit.Qubit, int]): The dictionary mapping the qarg to
the position. This is necessary to reconstruct the qarg order
over multiple gates in the combined single op node.
cycle_check (bool): When set to True this method will check that
Expand Down
13 changes: 13 additions & 0 deletions qiskit/pulse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
.. automodule:: qiskit.pulse.schedule
.. automodule:: qiskit.pulse.transforms
.. automodule:: qiskit.pulse.builder
.. automodule:: qiskit.pulse.model
.. currentmodule:: qiskit.pulse
Expand Down Expand Up @@ -168,3 +170,14 @@
)
from qiskit.pulse.library.samplers.decorators import functional_pulse
from qiskit.pulse.schedule import Schedule, ScheduleBlock

from qiskit.pulse.model import (
LogicalElement,
Qubit,
Coupler,
Frame,
GenericFrame,
QubitFrame,
MeasurementFrame,
MixedFrame,
)
Loading

0 comments on commit 07529f1

Please sign in to comment.