Skip to content

Commit

Permalink
Chore: comments and deprecated methods
Browse files Browse the repository at this point in the history
- Add comments to instruction property.
- Use new_bound for new PyDicts.
  • Loading branch information
raynelfss committed Apr 5, 2024
1 parent ecc4668 commit 506b1bd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions crates/accelerate/src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ impl Target {
&mut self,
py: Python<'_>,
instruction: PyObject,
properties: Option<&PyDict>,
properties: Option<Bound<PyDict>>,
name: Option<String>,
) {
// Unwrap properties
let properties: &PyDict = properties.unwrap_or(PyDict::new(py));
let properties: Bound<PyDict> = properties.unwrap_or(PyDict::new_bound(py));
// Unwrap instruction name
let mut instruction_name: String = match name {
Some(name) => name,
Expand Down Expand Up @@ -215,7 +215,9 @@ impl Target {

#[getter]
fn instructions(&self) -> PyResult<Vec<(PyObject, Vec<usize>)>> {
// Get list of instructions.
let mut instruction_list: Vec<(PyObject, Vec<usize>)> = 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 = (
Expand All @@ -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::<Target>()?;
Ok(())
}

0 comments on commit 506b1bd

Please sign in to comment.