Skip to content

Commit

Permalink
Fix: Corrections from Matthew's review
Browse files Browse the repository at this point in the history
- Use `format!` for repr method in `InstructionProperties`
- Rename `Variable` variant of `TargetInstruction` to `Variadic`.
- Remove `internal_name` attribute from `TargetOperation`.
- Remove `VariableOperation` class.
- Use `u32` for `granularity`, `pulse_alignment`, and `acquire_alignment`.
- Use `Option` to store nullable `concurrent_measurements.
- Use `&str` instead of `String` for most function arguments.
- Use `swap_remove` to deallocate items from the provided `properties` map in `add_instruction`.
- Avoid cloning instructions, use `to_object()` instead.
- Avoid using `.to_owned()`, use `.clone()` instead.
- Remove mention of `RandomState`, use `ahash::HashSet` instead.
- Move parameter check to python in `instruction_supported`.
- Avoid exposing private attributes, use the available ones instead.
- Filter out `Varidadic` Instructions as they're not supported in rust.
- Use peekable iterator to peak at the next qargs in `generate_non_global_op_names`.
- Rename `qarg_set` to `deduplicated_qargs` in `generate_non_global_op_names`.
- Return iterator instances instead of allocated `Vec`.
- Add `python_compare` and `python_is_instance` to perform object comparison with objects that satisfy the `ToPyObject` trait.
- Other small tweaks and fixes.
  • Loading branch information
raynelfss committed Jul 7, 2024
1 parent 1a61ebb commit 79752ee
Show file tree
Hide file tree
Showing 4 changed files with 262 additions and 280 deletions.
32 changes: 14 additions & 18 deletions crates/accelerate/src/target_transpiler/instruction_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,19 @@ impl InstructionProperties {
Ok(())
}

fn __repr__(&self, _py: Python<'_>) -> PyResult<String> {
let mut output = "InstructionProperties(".to_owned();
if let Some(duration) = self.duration {
output.push_str("duration=");
output.push_str(duration.to_string().as_str());
output.push_str(", ");
} else {
output.push_str("duration=None, ");
}

if let Some(error) = self.error {
output.push_str("error=");
output.push_str(error.to_string().as_str());
output.push_str(", ");
} else {
output.push_str("error=None, ");
}
Ok(output)
fn __repr__(&self, _py: Python<'_>) -> String {
format!(
"InstructionProperties(duration={}, error={})",
if let Some(duration) = self.duration {
duration.to_string()
} else {
"None".to_string()
},
if let Some(error) = self.error {
error.to_string()
} else {
"None".to_string()
}
)
}
}
Loading

0 comments on commit 79752ee

Please sign in to comment.