From bbb8033098d90b611a382db3b50d010fa677ec1e Mon Sep 17 00:00:00 2001 From: Jake Lishman Date: Wed, 19 Feb 2025 18:24:26 +0000 Subject: [PATCH] Remove accidentally-public methods from `QuantumCircuit` These were never really meant to be public at all, and we didn't even notice they existed publicly til we rewrote the `QuantumCircuit` documentation. --- qiskit/circuit/quantumcircuit.py | 89 ------------------- ...remove-circuit-cruft-30740668cf2f04e0.yaml | 13 +++ 2 files changed, 13 insertions(+), 89 deletions(-) create mode 100644 releasenotes/notes/remove-circuit-cruft-30740668cf2f04e0.yaml diff --git a/qiskit/circuit/quantumcircuit.py b/qiskit/circuit/quantumcircuit.py index e73769a42bc..868da61b95a 100644 --- a/qiskit/circuit/quantumcircuit.py +++ b/qiskit/circuit/quantumcircuit.py @@ -962,19 +962,6 @@ class QuantumCircuit: .. automethod:: decompose .. automethod:: reverse_bits - - Internal utilities - ================== - - These functions are not intended for public use, but were accidentally left documented in the - public API during the 1.0 release. They will be removed in Qiskit 2.0, but will be supported - until then. - - .. automethod:: cast - .. automethod:: cbit_argument_conversion - .. automethod:: cls_instances - .. automethod:: cls_prefix - .. automethod:: qbit_argument_conversion """ instances = 0 @@ -1456,35 +1443,12 @@ def __deepcopy__(self, memo=None): def _increment_instances(cls): cls.instances += 1 - @classmethod - @deprecate_func( - since=1.2, - removal_timeline="in the 2.0 release", - additional_msg="This method is only used as an internal helper " - "and will be removed with no replacement.", - ) - def cls_instances(cls) -> int: - """Return the current number of instances of this class, - useful for auto naming.""" - return cls.instances - @classmethod def _cls_instances(cls) -> int: """Return the current number of instances of this class, useful for auto naming.""" return cls.instances - @classmethod - @deprecate_func( - since=1.2, - removal_timeline="in the 2.0 release", - additional_msg="This method is only used as an internal helper " - "and will be removed with no replacement.", - ) - def cls_prefix(cls) -> str: - """Return the prefix to use for auto naming.""" - return cls.prefix - @classmethod def _cls_prefix(cls) -> str: """Return the prefix to use for auto naming.""" @@ -2347,20 +2311,6 @@ def __getitem__(self, item): """Return indexed operation.""" return self._data[item] - @staticmethod - @deprecate_func( - since=1.2, - removal_timeline="in the 2.0 release", - additional_msg="This method is only used as an internal helper " - "and will be removed with no replacement.", - ) - def cast(value: S, type_: Callable[..., T]) -> Union[S, T]: - """Best effort to cast value to type. Otherwise, returns the value.""" - try: - return type_(value) - except (ValueError, TypeError): - return value - @staticmethod def _cast(value: S, type_: Callable[..., T]) -> Union[S, T]: """Best effort to cast value to type. Otherwise, returns the value.""" @@ -2369,26 +2319,6 @@ def _cast(value: S, type_: Callable[..., T]) -> Union[S, T]: except (ValueError, TypeError): return value - @deprecate_func( - since=1.2, - removal_timeline="in the 2.0 release", - additional_msg="This method is only used as an internal helper " - "and will be removed with no replacement.", - ) - def qbit_argument_conversion(self, qubit_representation: QubitSpecifier) -> list[Qubit]: - """ - Converts several qubit representations (such as indexes, range, etc.) - into a list of qubits. - - Args: - qubit_representation: Representation to expand. - - Returns: - The resolved instances of the qubits. - """ - - return self._qbit_argument_conversion(qubit_representation) - def _qbit_argument_conversion(self, qubit_representation: QubitSpecifier) -> list[Qubit]: """ Converts several qubit representations (such as indexes, range, etc.) @@ -2404,25 +2334,6 @@ def _qbit_argument_conversion(self, qubit_representation: QubitSpecifier) -> lis qubit_representation, self.qubits, self._qubit_indices, Qubit ) - @deprecate_func( - since=1.2, - removal_timeline="in the 2.0 release", - additional_msg="This method is only used as an internal helper " - "and will be removed with no replacement.", - ) - def cbit_argument_conversion(self, clbit_representation: ClbitSpecifier) -> list[Clbit]: - """ - Converts several classical bit representations (such as indexes, range, etc.) - into a list of classical bits. - - Args: - clbit_representation : Representation to expand. - - Returns: - A list of tuples where each tuple is a classical bit. - """ - return self._cbit_argument_conversion(clbit_representation) - def _cbit_argument_conversion(self, clbit_representation: ClbitSpecifier) -> list[Clbit]: """ Converts several classical bit representations (such as indexes, range, etc.) diff --git a/releasenotes/notes/remove-circuit-cruft-30740668cf2f04e0.yaml b/releasenotes/notes/remove-circuit-cruft-30740668cf2f04e0.yaml new file mode 100644 index 00000000000..182545c4e6e --- /dev/null +++ b/releasenotes/notes/remove-circuit-cruft-30740668cf2f04e0.yaml @@ -0,0 +1,13 @@ +--- +upgrade_circuits: + - | + The :class:`.QuantumCircuit` methods: + + * ``cast`` + * ``cbit_argument_conversion`` + * ``cls_instances`` + * ``cls_prefix`` + * ``qbit_argument_conversion`` + + have been removed, following their deprecation in Qiskit 1.2. These methods were internal + helper functions, and never intended to be public API. No replacement is provided.