Add pretty printers for Statevec and DensityMatrix#503
Conversation
|
Thank you for your contribution! As noted in the preamble of #501, this issue is part of unitaryHACK 2026; therefore, contributions will be evaluated during the hackathon period, from June 3 to June 17, 2026. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #503 +/- ##
==========================================
- Coverage 89.97% 89.74% -0.24%
==========================================
Files 48 48
Lines 7015 7129 +114
==========================================
+ Hits 6312 6398 +86
- Misses 703 731 +28 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
thierry-martinez
left a comment
There was a problem hiding this comment.
Thank you very much for your contribution!
Could you please fix the issue that mypy has detected?
In addition, Codecov reports that some parts of your code are not covered by tests.
As you may have noticed, PR #523 and PR #524 address the same issue (#501). We invite you to cross‑review each other's work: PR reviews are an inherent part of software development, just as important as writing code. Moreover, this review process will help you position your PR relative to the others, allowing us to determine which contribution best resolves the issue.
| def _bra(label: str, output: OutputFormat) -> str: | ||
| if output == OutputFormat.LaTeX: | ||
| return rf"\langle {label}\rvert" | ||
| if output == OutputFormat.Unicode: |
There was a problem hiding this comment.
Using \bra{} would be more standard.
Summary\n- add complex-number pretty formatting for fractions, square-root constants, and phase exponentials\n- add statevector ket expansion rendering via
Statevec.draw()\n- add density-matrix outer-product rendering viaDensityMatrix.draw()\n- cover the new formatting helpers and draw methods with tests\n\nCloses #501\n\n## Testing\n-pytest tests/test_pretty_print.py -q\n-python3 -m ruff check graphix/pretty_print.py graphix/sim/statevec.py graphix/sim/density_matrix.py tests/test_pretty_print.py