-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: T2Op
enum for convenient local operations
#63
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awsome, thanks a lot!
We can definitely switch to this. Would you mind using these also in src/utils
(fn cx_gate
etc) and src/json/op.rs
?
|
||
pub(crate) fn build_simple_circuit( | ||
num_qubits: usize, | ||
f: impl FnOnce(&mut CircuitBuilder<DFGBuilder<Hugr>>) -> Result<(), BuildError>, | ||
) -> Result<Hugr, BuildError> { | ||
let qb_row = vec![QB_T; num_qubits]; | ||
let mut h = DFGBuilder::new(FunctionType::new(qb_row.clone(), qb_row))?; | ||
|
||
let qbs = h.input_wires(); | ||
|
||
let mut circ = h.as_circuit(qbs.into_iter().collect()); | ||
|
||
f(&mut circ)?; | ||
|
||
let qbs = circ.finish(); | ||
h.finish_hugr_with_outputs(qbs) | ||
} | ||
|
||
#[fixture] | ||
pub(crate) fn t2_bell_circuit() -> Hugr { | ||
let h = build_simple_circuit(2, |circ| { | ||
circ.append(T2Op::H, [0])?; | ||
circ.append(T2Op::CX, [0, 1])?; | ||
Ok(()) | ||
}); | ||
|
||
h.unwrap() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two functions should probably be removed for the time being.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add a test that checks to make sure fixture building succeeds - adds coverage of this module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry, didn't realise that. If you're going to use these anyways in future tests then we can just leave this as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent, thanks!
Uses strum to make loading from and adding to extension automated.
BREAKING CHANGE: the extension used for known ops changed from "quantum" to "quantum.tket2"