diff --git a/crates/circuit/src/circuit_data.rs b/crates/circuit/src/circuit_data.rs index dd2618f03f9a..1b11afc60921 100644 --- a/crates/circuit/src/circuit_data.rs +++ b/crates/circuit/src/circuit_data.rs @@ -361,6 +361,12 @@ impl CircuitData { .map(|ob| ob.clone_ref(py)) } + pub fn get_parameter_by_uuid(&self, py: Python, uuid: ParameterUuid) -> Option> { + self.param_table + .py_parameter_by_uuid(uuid) + .map(|ob| ob.clone_ref(py)) + } + /// Return the width of the circuit. This is the number of qubits plus the /// number of clbits. /// diff --git a/crates/circuit/src/parameter_table.rs b/crates/circuit/src/parameter_table.rs index 8825fbd71772..38cabf10c69f 100644 --- a/crates/circuit/src/parameter_table.rs +++ b/crates/circuit/src/parameter_table.rs @@ -225,6 +225,11 @@ impl ParameterTable { .map(|uuid| &self.by_uuid[uuid].object) } + /// Lookup the Python parameter object by uuid. + pub fn py_parameter_by_uuid(&self, uuid: ParameterUuid) -> Option<&Py> { + self.by_uuid.get(&uuid).map(|param| ¶m.object) + } + /// Get the (maybe cached) Python list of the sorted `Parameter` objects. pub fn py_parameters<'py>(&mut self, py: Python<'py>) -> Bound<'py, PyList> { if let Some(py_parameters) = self.py_parameters.as_ref() {