Skip to content

Commit

Permalink
Revert "Fix QuantumCircuit.assign_parameters docstring (#6546)" (#…
Browse files Browse the repository at this point in the history
…6696)

This PR included a deprecation removal which was invalid as not enough
time has passed. The deprecation occured in 0.17.0 which is not eligible
for removal until the 0.19.0 release. This PR can be repropoposed after
0.18.0 is released and quickly merged into 0.19.0.

This reverts commit 09f9c10.

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 8, 2021
1 parent ecde497 commit 1104041
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
3 changes: 3 additions & 0 deletions qiskit/circuit/library/n_local/n_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
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 @@ -793,10 +794,12 @@ 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: 11 additions & 4 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
from qiskit.utils.deprecation import deprecate_function, deprecate_arguments
from .parameterexpression import ParameterExpression
from .quantumregister import QuantumRegister, Qubit, AncillaRegister, AncillaQubit
from .classicalregister import ClassicalRegister, Clbit
Expand Down Expand Up @@ -2078,7 +2078,10 @@ def _unsorted_parameters(self):

return parameters

def assign_parameters(self, parameters, inplace=False):
@deprecate_arguments({"param_dict": "parameters"})
def assign_parameters(
self, parameters, inplace=False, param_dict=None
): # pylint: disable=unused-argument
"""Assign parameters to new parameters or values.
The keys of the parameter dictionary must be Parameter instances in the current circuit. The
Expand All @@ -2090,9 +2093,11 @@ def assign_parameters(self, parameters, inplace=False):
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 of ``QuantumCircuit.parameters``.
in the order they were inserted. You can call ``QuantumCircuit.parameters`` to check
this order.
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 @@ -2183,14 +2188,16 @@ def assign_parameters(self, parameters, inplace=False):
bound_circuit._assign_parameter(self.parameters[i], value)
return None if inplace else bound_circuit

def bind_parameters(self, values):
@deprecate_arguments({"value_dict": "values"})
def bind_parameters(self, values, value_dict=None): # pylint: disable=unused-argument
"""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

This file was deleted.

0 comments on commit 1104041

Please sign in to comment.