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: Add CircuitMut trait #138

Merged
merged 9 commits into from
Sep 29, 2023
Merged

feat: Add CircuitMut trait #138

merged 9 commits into from
Sep 29, 2023

Conversation

lmondada
Copy link
Contributor

@lmondada lmondada commented Sep 27, 2023

I needed this to remove qubits in patterns when they are empty.

I struggled a bit to figure out how to update the types correctly. I hope this is correct, but please have a close look at it, I do not know what I am doing.

@lmondada lmondada requested a review from ss2165 September 27, 2023 14:16
@lmondada
Copy link
Contributor Author

lmondada commented Sep 27, 2023

I'm changing this to also handle copyable wires, one minute!

EDIT: done!

@lmondada
Copy link
Contributor Author

lmondada commented Sep 27, 2023

shift_port will not act properly until CQCL/hugr#565 is resolved.

EDIT: I've added a work-around with a TODO to simplify once the issue is resolved.

Copy link
Member

@ss2165 ss2165 left a comment

Choose a reason for hiding this comment

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

I suggest a trait simplification but otherwise this seems ok to be, as you said elsewhere it is worth thinking about how the base api could be improved to avoid the shifting/updating workarounds

src/circuit.rs Outdated
@@ -120,18 +128,164 @@ pub trait Circuit: HugrView {
}
}

/// A circuit object that can be mutated.
pub trait CircuitMut: Circuit + HugrMut {
Copy link
Member

Choose a reason for hiding this comment

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

I'm pretty sure this can be defined without the :Circuit requirement (just replace calls to input() and output() with get_io).

Further i don't think it needs to be a trait, just a remove_empty_wire generic function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@lmondada lmondada requested a review from ss2165 September 29, 2023 10:21
@lmondada lmondada merged commit ae8b281 into main Sep 29, 2023
7 checks passed
@lmondada lmondada deleted the feat/circuit-mut branch September 29, 2023 12:22
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