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

fix: Commands iterator ignoring the hierarchy. #381

Merged
merged 2 commits into from
Jun 4, 2024

Conversation

aborgna-q
Copy link
Collaborator

The commands iterator did a toposort on the whole Hugr, ignoring the hierarchy.
This generated problems with #370, since circuits may now be nested somewhere in the hugr.
It would also have caused problems with circuit boxes, but we don't support that yet here.

We use a SiblingGraph now, to ensure that we only explore the top-level region of the circuit.
Subcircuits will be returned as a single command.

Adds a build_module_with_circuit helper to build circuits inside modules.

Closes #42.

@aborgna-q aborgna-q requested a review from ss2165 June 4, 2024 14:45
Copy link

codecov bot commented Jun 4, 2024

Codecov Report

Attention: Patch coverage is 81.39535% with 8 lines in your changes missing coverage. Please review.

Project coverage is 83.32%. Comparing base (3c7684f) to head (8dbe70e).

Files Patch % Lines
tket2/src/circuit/command.rs 82.60% 1 Missing and 3 partials ⚠️
tket2/src/utils.rs 80.00% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #381      +/-   ##
==========================================
+ Coverage   83.09%   83.32%   +0.22%     
==========================================
  Files          48       48              
  Lines        5040     5042       +2     
  Branches     4589     4591       +2     
==========================================
+ Hits         4188     4201      +13     
+ Misses        672      654      -18     
- Partials      180      187       +7     
Flag Coverage Δ
python 97.33% <ø> (ø)
rust 81.94% <81.39%> (+0.24%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

good spot

@aborgna-q aborgna-q added this pull request to the merge queue Jun 4, 2024
Merged via the queue into main with commit 50ee0fa Jun 4, 2024
16 checks passed
@aborgna-q aborgna-q deleted the ab/single-layer-commands branch June 4, 2024 15:25
github-merge-queue bot pushed a commit that referenced this pull request Jun 11, 2024
## 🤖 New release
* `tket2`: 0.1.0-alpha.1 -> 0.1.0-alpha.2

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

##
[0.1.0-alpha.2](tket2-v0.1.0-alpha.1...tket2-v0.1.0-alpha.2)
- 2024-06-11

### Bug Fixes
- Commands iterator ignoring the hierarchy.
([#381](#381))

### New Features
- Replace `Circuit::num_gates` with `num_operations`
([#384](#384))
- Utilities for loading compiled guppy circuits
([#393](#393))

### Refactor
- [**breaking**] Replace Circuit trait with a struct
([#370](#370))
- [**breaking**] Rename `tket2::json` into `tket2::serialize::pytket`
([#392](#392))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).
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.

Test nested circuit regions & command iterator.
2 participants