Skip to content

Commit

Permalink
put call to unsorted params outside of loop (#6112)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthew Treinish <[email protected]>
  • Loading branch information
Cryoris and mtreinish authored Mar 31, 2021
1 parent 6226c05 commit 2d69ee7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion qiskit/circuit/quantumcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2016,10 +2016,11 @@ def assign_parameters(self, parameters, inplace=False,
if isinstance(parameters, dict):
# unroll the parameter dictionary (needed if e.g. it contains a ParameterVector)
unrolled_param_dict = self._unroll_param_dict(parameters)
unsorted_parameters = self._unsorted_parameters()

# check that all param_dict items are in the _parameter_table for this circuit
params_not_in_circuit = [param_key for param_key in unrolled_param_dict
if param_key not in self._unsorted_parameters()]
if param_key not in unsorted_parameters]
if len(params_not_in_circuit) > 0:
raise CircuitError('Cannot bind parameters ({}) not present in the circuit.'.format(
', '.join(map(str, params_not_in_circuit))))
Expand Down

0 comments on commit 2d69ee7

Please sign in to comment.