Skip to content

Commit

Permalink
Merge branch 'main' into fix-backend-v1-pm-config-from
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] committed Mar 3, 2023
2 parents 78ef8e8 + 23e30f2 commit 87ed13a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
34 changes: 26 additions & 8 deletions qiskit/circuit/bit.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,23 @@ def __init__(self, register=None, index=None):

@property
def register(self):
"""Get bit's register."""
"""Get the register of an old-style bit.
.. deprecated:: 0.17
Use :meth:`.QuantumCircuit.find_bit` instead.
In modern Qiskit Terra (version 0.17+), bits are the fundamental object and registers are
aliases to collections of bits. A bit can be in many registers depending on the circuit, so
a single containing register is no longer a property of a bit. It is an error to access
this attribute on bits that were not constructed as "owned" by a register."""
if (self._register, self._index) == (None, None):
raise CircuitError("Attempt to query register of a new-style Bit.")

warnings.warn(
"Back-references to from Bit instances to their containing "
"Registers have been deprecated. Instead, inspect Registers "
"to find their contained Bits.",
"'Bit.register' is deprecated since Qiskit Terra 0.17 and will be removed "
"in a future release. Bits may be in more than one register. "
"Use 'QuantumCircuit.find_bit' to find all the containing registers within a circuit, "
"and the index of the bit within the circuit.",
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -70,14 +79,23 @@ def register(self):

@property
def index(self):
"""Get bit's index."""
"""Get the index of an old-style bit in the register that owns it.
.. deprecated:: 0.17
Use :meth:`.QuantumCircuit.find_bit` instead.
In modern Qiskit Terra (version 0.17+), bits are the fundamental object and registers are
aliases to collections of bits. A bit can be in many registers depending on the circuit, so
a single containing register is no longer a property of a bit. It is an error to access
this attribute on bits that were not constructed as "owned" by a register."""
if (self._register, self._index) == (None, None):
raise CircuitError("Attempt to query index of a new-style Bit.")

warnings.warn(
"Back-references to from Bit instances to their containing "
"Registers have been deprecated. Instead, inspect Registers "
"to find their contained Bits.",
"'Bit.index' is deprecated since Qiskit Terra 0.17 and will be removed "
"in a future release. Bits may be in more than one register. "
"Use 'QuantumCircuit.find_bit' to find all the containing registers within a circuit, "
"and the index of the bit within the circuit.",
DeprecationWarning,
stacklevel=2,
)
Expand Down
2 changes: 1 addition & 1 deletion qiskit/test/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def setUpClass(cls):
r"elementwise comparison failed.*",
r"The jsonschema validation included in qiskit-terra.*",
r"The DerivativeBase.parameter_expression_grad method.*",
r"Back-references to from Bit instances.*",
r"'Bit\.(register|index)' is deprecated.*",
r"The CXDirection pass has been deprecated",
r"The pauli_basis function with PauliTable.*",
# Caused by internal scikit-learn scipy usage
Expand Down

0 comments on commit 87ed13a

Please sign in to comment.