Skip to content

Commit 9439c8f

Browse files
1ucian0jakelishman
andauthored
Remove Bit.register and Bit.index (#10996)
* Remove Bit.register and Bit.index * remove impor * black * reno * Fixup release note --------- Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
1 parent f808fe5 commit 9439c8f

File tree

3 files changed

+10
-60
lines changed

3 files changed

+10
-60
lines changed

qiskit/circuit/bit.py

-47
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import copy
1717

1818
from qiskit.circuit.exceptions import CircuitError
19-
from qiskit.utils.deprecation import deprecate_func
2019

2120

2221
class Bit:
@@ -59,52 +58,6 @@ def __init__(self, register=None, index=None):
5958
self._hash = hash((self._register, self._index))
6059
self._repr = f"{self.__class__.__name__}({self._register}, {self._index})"
6160

62-
@property
63-
@deprecate_func(
64-
is_property=True,
65-
since="0.17",
66-
package_name="qiskit-terra",
67-
additional_msg=(
68-
"Instead, use :meth:`~qiskit.circuit.quantumcircuit.QuantumCircuit.find_bit` to find "
69-
"all the containing registers within a circuit and the index of the bit within the "
70-
"circuit."
71-
),
72-
)
73-
def register(self): # pylint: disable=bad-docstring-quotes
74-
"""Get the register of an old-style bit.
75-
76-
In modern Qiskit Terra (version 0.17+), bits are the fundamental object and registers are
77-
aliases to collections of bits. A bit can be in many registers depending on the circuit, so
78-
a single containing register is no longer a property of a bit. It is an error to access
79-
this attribute on bits that were not constructed as "owned" by a register."""
80-
if (self._register, self._index) == (None, None):
81-
raise CircuitError("Attempt to query register of a new-style Bit.")
82-
83-
return self._register
84-
85-
@property
86-
@deprecate_func(
87-
is_property=True,
88-
since="0.17",
89-
package_name="qiskit-terra",
90-
additional_msg=(
91-
"Instead, use :meth:`~qiskit.circuit.quantumcircuit.QuantumCircuit.find_bit` to find "
92-
"all the containing registers within a circuit and the index of the bit within the "
93-
"circuit."
94-
),
95-
)
96-
def index(self): # pylint: disable=bad-docstring-quotes
97-
"""Get the index of an old-style bit in the register that owns it.
98-
99-
In modern Qiskit Terra (version 0.17+), bits are the fundamental object and registers are
100-
aliases to collections of bits. A bit can be in many registers depending on the circuit, so
101-
a single containing register is no longer a property of a bit. It is an error to access
102-
this attribute on bits that were not constructed as "owned" by a register."""
103-
if (self._register, self._index) == (None, None):
104-
raise CircuitError("Attempt to query index of a new-style Bit.")
105-
106-
return self._index
107-
10861
def __repr__(self):
10962
"""Return the official string representing the bit."""
11063
if (self._register, self._index) == (None, None):
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
upgrade:
3+
- |
4+
The properties ``Bit.register`` and ``Bit.index`` are removed. They were deprecated in
5+
Qiskit 0.25 (released in April, 2021). The qubits and bits now live only in the context of
6+
a :class:`.QuantumCircuit`. The alternative to the properties is
7+
to use :meth:`.QuantumCircuit.find_bit` to find all the containing
8+
registers within a circuit and the index of the bit within the
9+
circuit.

test/python/circuit/test_bit.py

+1-13
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from unittest import mock
1818

1919
from qiskit.test import QiskitTestCase
20-
from qiskit.circuit import bit, QuantumRegister
20+
from qiskit.circuit import bit
2121

2222

2323
class TestBitClass(QiskitTestCase):
@@ -106,15 +106,3 @@ def test_new_style_bit_equality(self):
106106
self.assertEqual(bit1, bit1)
107107
self.assertNotEqual(bit1, bit2)
108108
self.assertNotEqual(bit1, 3.14)
109-
110-
def test_bit_register_backreferences_deprecated(self):
111-
"""Verify we raise a deprecation warning for register back-references."""
112-
113-
qr = QuantumRegister(3, "test_qr")
114-
qubit = qr[0]
115-
116-
with self.assertWarnsRegex(DeprecationWarning, "deprecated"):
117-
_ = qubit.index
118-
119-
with self.assertWarnsRegex(DeprecationWarning, "deprecated"):
120-
_ = qubit.register

0 commit comments

Comments
 (0)