Skip to content

Commit

Permalink
Fix QuantumCircuit.assign_parameters docstring (#6546)
Browse files Browse the repository at this point in the history
* Fix docstring of assign_parameters

and remove the deprecated arguments, as they have been deprecated > 3months ago

* add reno

* lint

* lint

* lint!

Co-authored-by: Kevin Krsulich <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 7, 2021
1 parent 40d7ee2 commit 09f9c10
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
3 changes: 0 additions & 3 deletions qiskit/circuit/library/n_local/n_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from qiskit.circuit.quantumregister import QuantumRegister
from qiskit.circuit import Instruction, Parameter, ParameterVector, ParameterExpression
from qiskit.circuit.parametertable import ParameterTable
from qiskit.utils.deprecation import deprecate_arguments

from ..blueprintcircuit import BlueprintCircuit

Expand Down Expand Up @@ -793,12 +792,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.
Expand Down
15 changes: 4 additions & 11 deletions qiskit/circuit/quantumcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,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
Expand Down Expand Up @@ -2128,10 +2128,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
Expand All @@ -2143,11 +2140,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
Expand Down Expand Up @@ -2238,16 +2233,14 @@ 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
circuit, use the :meth:`assign_parameters` method.
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
upgrade:
- |
Delete the arguments `param_dict` in :meth:`qiskit.circuit.QuantumCircuit.assign_parameters`
and `value_dict` in :meth:`qiskit.circuit.QuantumCircuit.bind_parameters`, which have been
deprecated in [PR 5759](https://github.com/Qiskit/qiskit-terra/pull/5759). Instead,
use the arguments `parameters` resp. `values`.
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.

0 comments on commit 09f9c10

Please sign in to comment.