Skip to content

Commit

Permalink
Fix QuantumCircuit.assign_parameters docstring
Browse files Browse the repository at this point in the history
Right before the 0.18.0 release we reverted Qiskit#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 Qiskit#6696 which just re-applies Qiskit#6546.

This reverts commit 1104041.
  • Loading branch information
mtreinish committed Jul 12, 2021
1 parent 5ca9675 commit ce17ac1
Show file tree
Hide file tree
Showing 3 changed files with 25 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 @@ -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

Expand Down Expand Up @@ -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.
Expand Down
15 changes: 4 additions & 11 deletions qiskit/circuit/quantumcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -2199,16 +2194,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,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.

0 comments on commit ce17ac1

Please sign in to comment.