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

chore: update hugr dependency #219

Merged
merged 4 commits into from
Nov 8, 2023
Merged

chore: update hugr dependency #219

merged 4 commits into from
Nov 8, 2023

Conversation

aborgna-q
Copy link
Collaborator

@aborgna-q aborgna-q commented Nov 7, 2023

This required a partial move from using Port everywhere to the more specific OutgoingPort and IncomingPort.

I'll open a separate issue for the more pervasive changes like updating the Units iterator and the portmatching module.
For now, we just cast and unwrap in those cases.

Requires CQCL/hugr#647

Copy link

codecov bot commented Nov 7, 2023

Codecov Report

Merging #219 (e33a6bf) into main (b358c02) will increase coverage by 0.08%.
Report is 1 commits behind head on main.
The diff coverage is 82.25%.

@@            Coverage Diff             @@
##             main     #219      +/-   ##
==========================================
+ Coverage   74.98%   75.06%   +0.08%     
==========================================
  Files          30       30              
  Lines        4018     4039      +21     
  Branches     4018     4039      +21     
==========================================
+ Hits         3013     3032      +19     
- Misses        825      827       +2     
  Partials      180      180              
Files Coverage Δ
tket2/src/circuit.rs 94.87% <100.00%> (+0.08%) ⬆️
tket2/src/portmatching.rs 82.75% <100.00%> (+1.27%) ⬆️
tket2/src/portmatching/pattern.rs 89.30% <100.00%> (ø)
tket2/src/circuit/command.rs 69.36% <92.30%> (+0.84%) ⬆️
tket2/src/circuit/units.rs 88.17% <50.00%> (-0.13%) ⬇️
tket2/src/portmatching/matcher.rs 76.28% <80.00%> (+0.33%) ⬆️
tket2/src/passes/chunks.rs 85.10% <76.92%> (-0.46%) ⬇️
tket2/src/portmatching/pyo3.rs 0.00% <0.00%> (ø)

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@@ -155,7 +155,7 @@ impl Chunk {
ConnectionTarget::TransitiveConnection(input_connection)
} else {
// Translate the original chunk node into the inserted node.
(*node_map.get(&node).unwrap(), port).into()
ConnectionTarget::InsertedOutput(*node_map.get(&node).unwrap(), port)
Copy link
Contributor

Choose a reason for hiding this comment

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

You could leave this line unchanged, right, as you are #[derive(...,From)] on ConnectionTarget and #[from] on Inserted(In,Out)put? I'd either use the From derivations or not derive them

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

dropped the From, the explicit version is more clear

let edge_prop =
PEdge::try_from_port(cmd.node(), in_offset, circuit).expect("Invalid HUGR");
let in_offset: IncomingPort = in_offset.into();
let edge_prop = PEdge::try_from_port(cmd.node(), in_offset.into(), circuit)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can do this more directly (avoiding in_offset) via Port::new_incoming

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We use in_offset below for linked_outputs, so we need the Incoming port.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok. (Personal taste but I am starting to like var = Foo::from(x) rather than var:Foo = x.into())

(cx_gate, NodeID::CopyNode(inp, Port::new_outgoing(1))),
(
cx_gate,
NodeID::CopyNode(inp, Port::new(Direction::Outgoing, 0))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
NodeID::CopyNode(inp, Port::new(Direction::Outgoing, 0))
NodeID::CopyNode(inp, Port::new_outgoing(0))

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That doesn't exist anymore.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I just found that myself, sorry. OutgoingPort::from(0).into(), hmmm. Add NodeID::new_copy(Node, impl Into<Port>) ?

@aborgna-q aborgna-q requested review from acl-cqc and removed request for acl-cqc November 7, 2023 15:29
Copy link
Contributor

@acl-cqc acl-cqc left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @aborgna-q !

@aborgna-q aborgna-q added this pull request to the merge queue Nov 8, 2023
Merged via the queue into main with commit 15a36fb Nov 8, 2023
11 checks passed
@aborgna-q aborgna-q deleted the chore/update-deps branch November 8, 2023 13:20
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