From 506b1bdddee7836d2ad424f8389a5076d56b92fb Mon Sep 17 00:00:00 2001 From: Raynel Sanchez <87539502+raynelfss@users.noreply.github.com> Date: Fri, 5 Apr 2024 09:49:12 -0400 Subject: [PATCH] Chore: comments and deprecated methods - Add comments to instruction property. - Use new_bound for new PyDicts. --- crates/accelerate/src/target.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/accelerate/src/target.rs b/crates/accelerate/src/target.rs index e5b90ae8c8b2..cf106cd815e0 100644 --- a/crates/accelerate/src/target.rs +++ b/crates/accelerate/src/target.rs @@ -94,11 +94,11 @@ impl Target { &mut self, py: Python<'_>, instruction: PyObject, - properties: Option<&PyDict>, + properties: Option>, name: Option, ) { // Unwrap properties - let properties: &PyDict = properties.unwrap_or(PyDict::new(py)); + let properties: Bound = properties.unwrap_or(PyDict::new_bound(py)); // Unwrap instruction name let mut instruction_name: String = match name { Some(name) => name, @@ -215,7 +215,9 @@ impl Target { #[getter] fn instructions(&self) -> PyResult)>> { + // Get list of instructions. let mut instruction_list: Vec<(PyObject, Vec)> = vec![]; + // Add all operations and dehash qargs. for op in self.gate_map.keys() { for qarg in self.gate_map[op].keys() { let instruction_pair = ( @@ -225,12 +227,13 @@ impl Target { instruction_list.push(instruction_pair); } } + // Return results. Ok(instruction_list) } } #[pymodule] -pub fn target(_py: Python, m: &PyModule) -> PyResult<()> { +pub fn target(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::()?; Ok(()) }