Skip to content

fix(hugr-py): solved graph rendering with Const nodes after applyingNormalizeGuppy#2744

Merged
nicolaassolini-qntm merged 2 commits intomainfrom
na/issue2726-graph-rendering-const-nodes
Dec 23, 2025
Merged

fix(hugr-py): solved graph rendering with Const nodes after applyingNormalizeGuppy#2744
nicolaassolini-qntm merged 2 commits intomainfrom
na/issue2726-graph-rendering-const-nodes

Conversation

@nicolaassolini-qntm
Copy link
Copy Markdown
Contributor

Solve issue Improve Python graph rendering for Const nodes #2726.

"When drawing the hugr in Python with DotRenderer the Const nodes take up an unreasonable amount of space which makes the HUGR hard to navigate. (This happens after applying the NormalizeGuppy pass to a HUGR containing parameterized gates)."

Defined the method __str__ to the Extension(Value) class in hugr-py/src/hugr/val.py

@nicolaassolini-qntm nicolaassolini-qntm requested a review from a team as a code owner December 9, 2025 18:04
@nicolaassolini-qntm nicolaassolini-qntm linked an issue Dec 9, 2025 that may be closed by this pull request
@codecov
Copy link
Copy Markdown

codecov bot commented Dec 9, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 83.36%. Comparing base (4f021a7) to head (897ac6e).
⚠️ Report is 30 commits behind head on main.

Files with missing lines Patch % Lines
hugr-py/src/hugr/val.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2744      +/-   ##
==========================================
- Coverage   83.36%   83.36%   -0.01%     
==========================================
  Files         267      267              
  Lines       52505    52507       +2     
  Branches    47214    47214              
==========================================
+ Hits        43773    43774       +1     
- Misses       6354     6355       +1     
  Partials     2378     2378              
Flag Coverage Δ
python 88.75% <50.00%> (-0.02%) ⬇️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@acl-cqc
Copy link
Copy Markdown
Contributor

acl-cqc commented Dec 12, 2025

Should we instead reapply some DCE to remove the unused Consts?

We might also want to consider hash-consing identical Consts into a single node, at least for those which can be hashed ;)

Copy link
Copy Markdown
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.

The tests are failing due to formatting, try running just format (or just check) to fix that

@aborgna-q
Copy link
Copy Markdown
Collaborator

Should we instead reapply some DCE to remove the unused Consts?

I think the constant folding pass will remove the unneeded constants already.

And merging identical const may be doable at load time? But it should be easy to write a pass for it

@nicolaassolini-qntm
Copy link
Copy Markdown
Contributor Author

The tests are failing due to formatting, try running just format (or just check) to fix that

I committed the file properly formatted

@nicolaassolini-qntm nicolaassolini-qntm added this pull request to the merge queue Dec 23, 2025
Merged via the queue into main with commit d996690 Dec 23, 2025
28 of 29 checks passed
@nicolaassolini-qntm nicolaassolini-qntm deleted the na/issue2726-graph-rendering-const-nodes branch December 23, 2025 14:21
github-merge-queue bot pushed a commit that referenced this pull request Jan 5, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.15.0](hugr-py-v0.14.2...hugr-py-v0.15.0)
(2026-01-02)


### ⚠ BREAKING CHANGES

* ValueArray is gone, as is LinearizeArrayPass
* **hugr-py:** Removes `extensions` field of `val.Extension`.

### Features

* `collated_digitstring_counts` to extend bitstring collation to digits
([#2788](#2788))
([191c473](191c473))
* **hugr-py:** Remove `extensions` field of `val.Extension`.
([#2686](#2686))
([911c089](911c089))
* Make `ComposablePass.__call__` return a Hugr
([#2697](#2697))
([dbf8c8e](dbf8c8e))
* Result type for ComposablePasses
([#2703](#2703))
([b8df28e](b8df28e))


### Bug Fixes

* **hugr-py:** solved graph rendering with `Const` nodes after
applying`NormalizeGuppy`
([#2744](#2744))
([d996690](d996690))
* set hugr field of `PassResult` correctly
([#2715](#2715))
([d860722](d860722))


### Code Refactoring

* Delete ValueArray
([#2760](#2760))
([b3cdc4e](b3cdc4e))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

Improve Python graph rendering for Const nodes

3 participants