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: high(-er) level rule, find, apply API #177

Merged
merged 3 commits into from
Oct 9, 2023
Merged

feat: high(-er) level rule, find, apply API #177

merged 3 commits into from
Oct 9, 2023

Conversation

ss2165
Copy link
Member

@ss2165 ss2165 commented Oct 9, 2023

Only returns first found match for now

@ss2165 ss2165 requested a review from aborgna-q October 9, 2023 12:05
@ss2165 ss2165 changed the title Feat/rule_api feat: high(-er) level rule, find, apply API Oct 9, 2023
Copy link
Collaborator

@aborgna-q aborgna-q left a 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) {
Copy link
Collaborator

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]);
Copy link
Collaborator

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);
Copy link
Collaborator

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?

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.e by defining some trait? Possibly but I fear surprise errors when conversion fails. Will raise issue.

@ss2165 ss2165 merged commit e2f8548 into main Oct 9, 2023
@ss2165 ss2165 deleted the feat/rule_api branch October 9, 2023 13:36
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