mirror of https://github.com/Qiskit/qiskit.git
38 lines
1.3 KiB
YAML
38 lines
1.3 KiB
YAML
---
|
|
features:
|
|
- |
|
|
A new :meth:`~qiskit.circuit.QuantumCircuit.find_bit` method has
|
|
been added to the :class:`~qiskit.circuit.QuantumCircuit` class,
|
|
which allows lookups of the index and registers of a provided
|
|
:class:`~qiskit.circuit.Bit` on the given circuit. The method
|
|
returns a two-element ``namedtuple`` containing 0) the index of the ``Bit``
|
|
in either :attr:`~qiskit.circuit.QuantumCircuit.qubits` (for
|
|
a :class:`~qiskit.circuit.Qubit`) or
|
|
:attr:`~qiskit.circuit.QuantumCircuit.clbits` (for a
|
|
:class:`~qiskit.circuit.Clbit`) and 1) a list of length-2 tuples
|
|
containing each circuit :class:`~qiskit.circuit.Register` which
|
|
contains the ``Bit``, and the index in that ``Register`` at which the
|
|
``Bit`` can be found.
|
|
|
|
For example:
|
|
|
|
.. code-block:: python
|
|
|
|
from qiskit.circuit import QuantumCircuit, QuantumRegister, Qubit
|
|
|
|
reg1 = QuantumRegister(3, 'foo')
|
|
qubit = Qubit()
|
|
reg2 = QuantumRegister(2, 'bar')
|
|
|
|
qc = QuantumCircuit(reg1, [qubit], reg2)
|
|
|
|
print(qc.find_bit(reg1[2]))
|
|
print(qc.find_bit(qubit))
|
|
|
|
would generate:
|
|
|
|
.. code-block:: python
|
|
|
|
BitLocations(index=2, registers=[(QuantumRegister(3, 'foo'), 2)])
|
|
BitLocations(index=3, registers=[])
|