Skip to content
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

Merged
merged 4 commits into from
Aug 30, 2023
Merged

feat: T2Op enum for convenient local operations #63

merged 4 commits into from
Aug 30, 2023

Conversation

ss2165
Copy link
Member

@ss2165 ss2165 commented Aug 30, 2023

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"

@ss2165 ss2165 requested a review from lmondada August 30, 2023 09:15
Copy link
Contributor

@lmondada lmondada left a 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?

Comment on lines +204 to +231

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()
}
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

@ss2165 ss2165 requested a review from lmondada August 30, 2023 09:48
Copy link
Contributor

@lmondada lmondada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent, thanks!

@ss2165 ss2165 merged commit 0247286 into main Aug 30, 2023
5 checks passed
@ss2165 ss2165 deleted the feat/t2ops branch August 30, 2023 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants