Skip to content

Commit

Permalink
Remove QuantumCircuit.bind_parameters (#11434)
Browse files Browse the repository at this point in the history
* Remove `QuantumCircuit.bind_parameters`

This expires the deprecation on `bind_parameters` in favour of
`assign_parameters`, which is a drop-in replacement with its defaults.

* Fix lint
  • Loading branch information
jakelishman authored Dec 19, 2023
1 parent 9439c8f commit 238f38a
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 173 deletions.
35 changes: 0 additions & 35 deletions qiskit/circuit/quantumcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3163,41 +3163,6 @@ def _unroll_param_dict(
out[parameter] = value
return out

@deprecate_func(additional_msg=("Use assign_parameters() instead"), since="0.45.0")
def bind_parameters(
self, values: Union[Mapping[Parameter, float], Sequence[float]]
) -> "QuantumCircuit":
"""Assign numeric parameters to values yielding a new circuit.
If the values are given as list or array they are bound to the circuit in the order
of :attr:`parameters` (see the docstring for more details).
To assign new Parameter objects or bind the values in-place, without yielding a new
circuit, use the :meth:`assign_parameters` method.
Args:
values: ``{parameter: value, ...}`` or ``[value1, value2, ...]``
Raises:
CircuitError: If values is a dict and contains parameters not present in the circuit.
TypeError: If values contains a ParameterExpression.
Returns:
Copy of self with assignment substitution.
"""
if isinstance(values, dict):
if any(isinstance(value, ParameterExpression) for value in values.values()):
raise TypeError(
"Found ParameterExpression in values; use assign_parameters() instead."
)
return self.assign_parameters(values)
else:
if any(isinstance(value, ParameterExpression) for value in values):
raise TypeError(
"Found ParameterExpression in values; use assign_parameters() instead."
)
return self.assign_parameters(values)

def barrier(self, *qargs: QubitSpecifier, label=None) -> InstructionSet:
"""Apply :class:`~.library.Barrier`. If ``qargs`` is empty, applies to all qubits
in the circuit.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
upgrade:
- |
The method ``QuantumCircuit.bind_parameters`` has been removed, following its deprecation in
Qiskit 0.45. You can use :meth:`.QuantumCircuit.assign_parameters` as a drop-in replacement
with all its defaults, and it also exposes additional features over the old method.
Loading

0 comments on commit 238f38a

Please sign in to comment.