Skip to content

Commit

Permalink
Fix: Use ParameterUuid as keys for assign_parameter_from_mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
raynelfss committed Aug 10, 2024
1 parent 87999f1 commit 9e84225
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions crates/circuit/src/circuit_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1092,17 +1092,22 @@ impl CircuitData {
)
}

/// Assigns parameters to circuit data based on a mapping of `Param` : `Param`.
/// This mapping assumes that the provided `Param` keys are instances of `ParameterExpression`.
/// Assigns parameters to circuit data based on a mapping of `ParameterUuid` : `Param`.
/// This mapping assumes that the provided `ParameterUuid` keys are instances
/// of `ParameterExpression`.
pub fn assign_parameters_from_mapping<I>(&mut self, py: Python, iter: I) -> PyResult<()>
where
I: IntoIterator<Item = (Param, Param)>,
I: IntoIterator<Item = (ParameterUuid, Param)>,
{
let mut items = Vec::new();
for (param_obj, value) in iter {
let param_obj = param_obj.to_object(py);
let uuid = ParameterUuid::from_parameter(param_obj.bind(py))?;
items.push((param_obj, value, self.param_table.pop(uuid)?));
for (param_uuid, value) in iter {
// Assume all the Parameters are already in the circuit
let param_obj = self.get_parameter_by_uuid(param_uuid);
items.push((
param_obj.unwrap().clone_ref(py),
value,
self.param_table.pop(param_uuid)?,
));
}
self.assign_parameters_inner(py, items)
}
Expand Down

0 comments on commit 9e84225

Please sign in to comment.