-
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: high(-er) level rule, find, apply API #177
Conversation
Only returns first found match for now
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.
This looks useful, specially as a simple API to play around with.
We could also move Rule
to the rust crate at some point, as a way to define straightforward substitution rules (probably useful for tests).
pyrs/src/lib.rs
Outdated
SerialCircuit::encode(&self.0)?.to_tket1() | ||
} | ||
|
||
fn apply_match(&mut self, rw: CircuitRewrite) { |
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.
Export CircuitRewrite
from the patterns module.
#[derive(Clone)] | ||
#[pyclass] | ||
/// A rewrite rule defined by a left hand side and right hand side of an equation. | ||
pub struct Rule(pub [Hugr; 2]); |
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.
Move this to a submodule. (And T2Circuit
to circuit.rs
).
pyrs/src/lib.rs
Outdated
|
||
#[pyclass] | ||
/// A manager for tket 2 operations on a tket 1 Circuit. | ||
pub struct T2Circuit(Hugr); |
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.
Having this is nice for avoiding unnecessary roundtrips, but it'd be nice to be able to use this interchangeably with TKET1 circs. Open an issue to investigate options?
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.e by defining some trait? Possibly but I fear surprise errors when conversion fails. Will raise issue.
Only returns first found match for now