From ce17ac184a9eb8aeea26c5412891a31aeab47f2b Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Mon, 12 Jul 2021 16:22:59 -0400 Subject: [PATCH] Fix ``QuantumCircuit.assign_parameters`` docstring Right before the 0.18.0 release we reverted #6546 because it was a bit too quick to complete a deprecation. Now that 0.18.0 has been released we can now remove the deprecated functionality and this commit reverts PR #6696 which just re-applies #6546. This reverts commit 1104041cfb95e61c7acc2ee4c99c207ab7bea08e. --- qiskit/circuit/library/n_local/n_local.py | 3 --- qiskit/circuit/quantumcircuit.py | 15 ++++--------- ...sign-parameters-args-9712d7d01e82c390.yaml | 21 +++++++++++++++++++ 3 files changed, 25 insertions(+), 14 deletions(-) create mode 100644 releasenotes/notes/remove-deprecated-assign-parameters-args-9712d7d01e82c390.yaml diff --git a/qiskit/circuit/library/n_local/n_local.py b/qiskit/circuit/library/n_local/n_local.py index 9b635deb9d76..7a207fc9c527 100644 --- a/qiskit/circuit/library/n_local/n_local.py +++ b/qiskit/circuit/library/n_local/n_local.py @@ -22,7 +22,6 @@ from qiskit.circuit import Instruction, Parameter, ParameterVector, ParameterExpression from qiskit.circuit.parametertable import ParameterTable from qiskit.exceptions import QiskitError -from qiskit.utils.deprecation import deprecate_arguments from ..blueprintcircuit import BlueprintCircuit @@ -794,12 +793,10 @@ def add_layer( return self - @deprecate_arguments({"param_dict": "parameters"}) def assign_parameters( self, parameters: Union[dict, List[float], List[Parameter], ParameterVector], inplace: bool = False, - param_dict: Optional[dict] = None, ) -> Optional[QuantumCircuit]: """Assign parameters to the n-local circuit. diff --git a/qiskit/circuit/quantumcircuit.py b/qiskit/circuit/quantumcircuit.py index 7989405b5b68..3d17f55e09d8 100644 --- a/qiskit/circuit/quantumcircuit.py +++ b/qiskit/circuit/quantumcircuit.py @@ -30,7 +30,7 @@ from qiskit.qasm.qasm import Qasm from qiskit.qasm.exceptions import QasmError from qiskit.circuit.exceptions import CircuitError -from qiskit.utils.deprecation import deprecate_function, deprecate_arguments +from qiskit.utils.deprecation import deprecate_function from .parameterexpression import ParameterExpression from .quantumregister import QuantumRegister, Qubit, AncillaRegister, AncillaQubit from .classicalregister import ClassicalRegister, Clbit @@ -2089,10 +2089,7 @@ def _unsorted_parameters(self): return parameters - @deprecate_arguments({"param_dict": "parameters"}) - def assign_parameters( - self, parameters, inplace=False, param_dict=None - ): # pylint: disable=unused-argument + def assign_parameters(self, parameters, inplace=False): """Assign parameters to new parameters or values. The keys of the parameter dictionary must be Parameter instances in the current circuit. The @@ -2104,11 +2101,9 @@ def assign_parameters( parameter values. If a dict, it specifies the mapping from ``current_parameter`` to ``new_parameter``, where ``new_parameter`` can be a new parameter object or a numeric value. If an iterable, the elements are assigned to the existing parameters - in the order they were inserted. You can call ``QuantumCircuit.parameters`` to check - this order. + in the order of ``QuantumCircuit.parameters``. inplace (bool): If False, a copy of the circuit with the bound parameters is returned. If True the circuit instance itself is modified. - param_dict (dict): Deprecated, use ``parameters`` instead. Raises: CircuitError: If parameters is a dict and contains parameters not present in the @@ -2199,8 +2194,7 @@ def assign_parameters( bound_circuit._assign_parameter(self.parameters[i], value) return None if inplace else bound_circuit - @deprecate_arguments({"value_dict": "values"}) - def bind_parameters(self, values, value_dict=None): # pylint: disable=unused-argument + def bind_parameters(self, values): """Assign numeric parameters to values yielding a new circuit. To assign new Parameter objects or bind the values in-place, without yielding a new @@ -2208,7 +2202,6 @@ def bind_parameters(self, values, value_dict=None): # pylint: disable=unused-ar Args: values (dict or iterable): {parameter: value, ...} or [value1, value2, ...] - value_dict (dict): Deprecated, use ``values`` instead. Raises: CircuitError: If values is a dict and contains parameters not present in the circuit. diff --git a/releasenotes/notes/remove-deprecated-assign-parameters-args-9712d7d01e82c390.yaml b/releasenotes/notes/remove-deprecated-assign-parameters-args-9712d7d01e82c390.yaml new file mode 100644 index 000000000000..8590bdf6f7b6 --- /dev/null +++ b/releasenotes/notes/remove-deprecated-assign-parameters-args-9712d7d01e82c390.yaml @@ -0,0 +1,21 @@ +--- +upgrade: + - | + The deprecated argument ``param_dict`` of the + :meth:`~qiskit.circuit.QuantumCircuit.assign_parameters` method of the + :class:`~qiskit.circuit.QuantumCircuit` class has been removed and no + longer exists. This argument was deprecated as part of the 0.17.0 release. + Instead you should use the ``parameters`` argument on the method. + - | + The deprecated argument ``value_dict`` + of the :meth:`qiskit.circuit.QuantumCircuit.bind_parameters` method of the + :class:`~qiskit.circuit.QuantumCircuit` class has been removed and no + longer exist. These arguments were deprecated as part of the 0.17.0 release. + Instead you should use the ``values`` argument on the method. +fixes: + - | + Fix the statement about the parameter order if the parameters are provided as + iteratble and not dictionary in + :meth:`qiskit.circuit.QuantumCircuit.assign_parameters`. The parameters are not + sorted by insertion but by name, with the special case that the order of a + :class:`~qiskit.circuit.ParameterVector` is maintained.