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

refactor: Drop dead code from circuits, Hugr updates #30

Merged
merged 5 commits into from
Jul 11, 2023

Conversation

aborgna-q
Copy link
Collaborator

This is mostly a code cleanup.

  • Defines Circuit as a trait on top of HugrView, and adds a couple of useful accessors (mostly TODOs).
  • Drops a lot of stale commented-out code that we can now delegate to the hugr crate.

@aborgna-q aborgna-q requested a review from croyzor July 6, 2023 09:47
@aborgna-q
Copy link
Collaborator Author

Moved Command and related structs to a submodule, to clean a bit circuit.rs

@ss2165 ss2165 self-requested a review July 11, 2023 08:59
todo!()
}

fn name(&self) -> SmolStr {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be indented? Do we not have the same formatting checks here as in hugr?

Copy link
Collaborator Author

@aborgna-q aborgna-q Jul 11, 2023

Choose a reason for hiding this comment

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

This module is commented out in circuit.rs (because this doesn't compile), so rustfmt doesn't process it.

use super::operation::ToCircuitFail;
//! Implementation of Hugr's CustomOp trait for the TKET1 bindings in `tket-rs`.
//!
//! TODO: This cannot be defined here. Should we do it in `hugr` or in `tket-rs`?
Copy link
Contributor

Choose a reason for hiding this comment

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

After a bit of thought, I don't know. Maybe some of these TODOs should be opened as discussions?

/// Otherwise, it is described by an internal [`Wire`].
//
// TODO Better name?
// TODO Merge this with CircuitBuilder::AppendWire?
Copy link
Member

Choose a reason for hiding this comment

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

yes I think rename AppendWire to Unit and just use that

src/circuit.rs Outdated
Comment on lines 71 to 72
+ petgraph::visit::IntoNeighborsDirected
+ petgraph::visit::IntoNodeIdentifiers
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is not quite right, as IntoNeighborsDirected and IntoNodeIdentifiers are implemented on references, so 'g T. I'm trying to write that, but constraining the lifetimes is a bit of a headache.

Changing the traits to the new Region trait in hugr should be straightforward once that's solved.

@aborgna-q
Copy link
Collaborator Author

aborgna-q commented Jul 11, 2023

I added a last commit with the constraints on references and hugr::Region for all else.

We now have a lifetime parameter in Circuit (which makes sense), but still have some ugly petgraph traits on the references (which doesn't). Since this is working, I'll merge it for now and open an issue to try to clean it up later.

I'll also

  • Open the TKET1 opaque ops issue suggested by Craig (that's related to fixing OpDefs)
  • Go rename CircuitBuilder::AppendWire in Hugr, and open an issue to use that once that's merged.

@aborgna-q aborgna-q merged commit b9a7750 into main Jul 11, 2023
5 checks passed
@aborgna-q aborgna-q deleted the refactor/circuits branch July 13, 2023 10:53
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.

3 participants