Skip to content

Pretty print #245

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

Open
wants to merge 230 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
230 commits
Select commit Hold shift + click to select a range
1699fe8
Refacto including new command classes. Some tests are still not passi…
benjvmin93 Apr 8, 2024
459287b
tests OK
benjvmin93 Apr 10, 2024
4fe2f97
new circuit instruction classes
benjvmin93 Apr 12, 2024
8e522a0
apply changes from instruction class in benchmark method
benjvmin93 Apr 12, 2024
f8bbcbd
made control instructions inherit from OneQubitInstruction
benjvmin93 Apr 12, 2024
9ee5d97
update instruction determination from name to class instance + remove…
benjvmin93 Apr 12, 2024
bfb2a53
update match for instructions and commands with an attribute to diffe…
benjvmin93 Apr 16, 2024
7829e73
improved _find_op_to_be_moved + test execution speed
benjvmin93 Apr 17, 2024
35ace68
improve _reorder_patter
benjvmin93 Apr 17, 2024
1e98cab
warnings to see execution time for tests
benjvmin93 Apr 17, 2024
766de39
black formatting
benjvmin93 Apr 18, 2024
83d979a
removed debug warnings + black
benjvmin93 May 23, 2024
ede1a78
fixed all conflicts
benjvmin93 May 24, 2024
eda4a46
typing + replace match by if/elif/else and make tests pass
benjvmin93 May 24, 2024
e840905
format
benjvmin93 May 24, 2024
923a15b
Merge branch 'master' into master
benjvmin93 May 24, 2024
d468480
fix test
benjvmin93 May 24, 2024
6e17dbf
Merge branch 'master' into master
benjvmin93 May 25, 2024
1bc3992
Merge remote-tracking branch 'upstream/master'
benjvmin93 Jun 3, 2024
d242e06
changes for PR
benjvmin93 Jun 3, 2024
e23caee
update plane attribute from M command to graphix.pauli.Plane
benjvmin93 Jun 5, 2024
037315a
update get_meas_plane more symbolic implem
benjvmin93 Jun 5, 2024
aacc569
more symbolic get_meas_plane using Pauli and Plane methods
benjvmin93 Jun 5, 2024
d11fd82
updates related to pr
benjvmin93 Jun 21, 2024
791378a
merged remote repo + update apply_correction method with command class
Jun 26, 2024
aba3ebb
fixed test + update apply_clifford method
Jun 26, 2024
b0c05ec
Fix diff
thierry-martinez Jul 4, 2024
c19d12b
Black transpiler
thierry-martinez Jul 5, 2024
a38b2a4
Fix review comments
thierry-martinez Jul 5, 2024
6d9c897
Remove match
thierry-martinez Jul 5, 2024
67b365d
Update get_corrections_from_pattern
thierry-martinez Jul 5, 2024
cd6501c
Add test for get_corrections_from_pattern
thierry-martinez Jul 5, 2024
026c41c
Remove comments
thierry-martinez Jul 5, 2024
dc94a37
Remove comments
thierry-martinez Jul 5, 2024
8fcd1b8
Remove comments
thierry-martinez Jul 5, 2024
9789756
Remove comments
thierry-martinez Jul 5, 2024
778f709
Check measure planes in gflow functions
thierry-martinez Jul 5, 2024
474165f
:heavy_plus_sign: Add eval_type_backport
EarlMilktea Jul 5, 2024
47242df
:recycle: Use __future__
EarlMilktea Jul 5, 2024
1c22911
Merge pull request #1 from TeamGraphix/review-pr155
benjvmin93 Jul 9, 2024
6c0e690
first commit pretty_print + notebook example
benjvmin93 Dec 3, 2024
24e17dc
turn dict into list of str + format
benjvmin93 Dec 4, 2024
a93c662
added to_qasm3 method. Need to implement to_QASM3() for instructions
benjvmin93 Dec 16, 2024
b314626
added abstract method to_qasm3 instruction
benjvmin93 Dec 16, 2024
29f6b1f
added to_qasm3 method for circuit instructions
benjvmin93 Dec 17, 2024
e3d75d4
circuit and instructions to_qasm3 methods
Jan 7, 2025
2d3864e
requirement for qiskit visualiwation
Jan 7, 2025
26b8a91
update str + circuit.draw methods
Jan 7, 2025
da6ca35
added test to make sure circuit.draw() doesn't raise exception.
Jan 8, 2025
9b572d2
to_latex pattern + command methods
Jan 13, 2025
df5a733
Merge remote-tracking branch 'upstream/master'
Jan 16, 2025
a2a0f2e
Merge branch 'master' into pretty-print
Jan 16, 2025
9cb6c0f
fix instruction file to synchronize with master
Jan 16, 2025
fe18260
rewrote circuit pretty print for master sync
Jan 16, 2025
fe29cb7
remove old useless notebook
Jan 16, 2025
d41d1f0
moved qiskit import directly into draw() method + remove useless matp…
Jan 16, 2025
d389062
update print_pattern to __str__ + draw method for pattern. Need to fi…
Jan 16, 2025
76cced9
fix _latex_file_to_image method
Jan 27, 2025
8662b9e
remove debug print
Jan 27, 2025
39e44bd
__str__ method for commands
Feb 4, 2025
12eb951
restored print_pattern + update method name to to_png
Feb 4, 2025
e87c3d0
cmd to unicode
Feb 4, 2025
3e4365d
pattern to_unicode method
Feb 4, 2025
34d9e32
added qiskit_qasm3_import for circuit drawing
Feb 4, 2025
295781e
fixed small issues in command draw representations
Feb 4, 2025
5d6960f
factorized code with to_latex method that only returns a string of th…
Feb 4, 2025
2fb5a72
Merge remote-tracking branch 'upstream/master'
Feb 5, 2025
b9b3a47
sync master with pretty-print branch
Feb 5, 2025
b98cba7
Merge branch 'master' into pretty-print -> removed get_local_pattern …
Feb 5, 2025
49afeaa
added return type for drawing methods
Feb 5, 2025
3a02de4
update changelog for PR
Feb 5, 2025
65d5381
ruff formatting
Feb 5, 2025
b9d67d8
format
Feb 5, 2025
67994aa
consistency with master sync
Feb 5, 2025
3595c49
format
Feb 5, 2025
647e6df
added documentation + format
Feb 5, 2025
1b8a5f8
ruff
Feb 5, 2025
04cf092
added draw("png") in test_pattern
Feb 5, 2025
f3aa1cb
update draw tests
benjvmin93 Feb 10, 2025
62e01a4
ruff for PR
Feb 10, 2025
c0af200
ruff for PR
Feb 10, 2025
2f633c7
mypy PR
Feb 10, 2025
d55a6bc
typing
Feb 10, 2025
02ba115
ruff
Feb 10, 2025
45708d6
removed command draw methods from KindChecker class
Feb 10, 2025
8548b2b
update to_qasm3 arg type to Instruction
Feb 10, 2025
feb79d1
fix mypy errors
Feb 10, 2025
da31961
ruff format
Feb 10, 2025
cbf3851
changed deprecated typing
Feb 10, 2025
0885fd2
removed unused variables
Feb 10, 2025
87aa6d4
added setup texlive github action
Feb 10, 2025
058a919
moved call to texlive setup action in cov.yml
Feb 10, 2025
18b2a6d
fix error cov.yml
Feb 10, 2025
8a397ea
added poppler-utils
Feb 10, 2025
becf927
put texlive installation in CI.yml
Feb 11, 2025
6c7460e
texlive installation in cov.yml
Feb 11, 2025
2343b93
fix yaml syntax
Feb 11, 2025
d77bb43
Update cov.yml
benjvmin93 Feb 11, 2025
53c3530
added sudo for permissions
Feb 11, 2025
fdd679b
Merge branch 'pretty-print-integrate-texlive-ci' of github.com:benjvm…
Feb 11, 2025
23e4bf5
Update ci.yml
benjvmin93 Feb 11, 2025
067f3b3
Update cov.yml
benjvmin93 Feb 11, 2025
835c334
added -y option in CI
Feb 11, 2025
f078847
added qcircuit latex package
Feb 11, 2025
4a9262e
locate debug
Feb 11, 2025
d34648f
update CI
Feb 11, 2025
954a761
remove updatedb
Feb 11, 2025
e4fdc35
added qcircuit package in github texlive action
Feb 11, 2025
2ab157b
update latex packages to scheme-full
Feb 11, 2025
aa4535e
removed scheme-full for specific packages
Feb 11, 2025
ad6d4df
set back to scheme-basic
Feb 11, 2025
3ced4ad
write permission for generating pdf files from latex ?
Feb 11, 2025
057ee4f
added debug action
Feb 11, 2025
af01ff9
add package dependencies
Feb 11, 2025
9399e73
xypic
Feb 11, 2025
e764f55
remove tmate session action
Feb 11, 2025
5288b40
fix xypic name + cleaned ci
Feb 11, 2025
3959bf9
skip tests if no latex installed
Feb 11, 2025
ea708a8
update CI for specific os
Feb 11, 2025
ff391fe
ruff format fix
Feb 11, 2025
a955965
format
Feb 11, 2025
6a665ee
update poppler
Feb 11, 2025
be244f3
change find_executable to which bc of deprecation
Feb 11, 2025
9610edc
moved pylatexenc from requirements-dev to requirements
Feb 11, 2025
ea43b36
cleaned command file using f string convention, reduced redundant cod…
Feb 18, 2025
a2108f5
use f string convention in to_qasm3 Instruction method
Feb 18, 2025
ebca302
remove print debug
Feb 18, 2025
9e303ca
cleaner code: use pathlib + move builtin module imports at toplevel
Feb 18, 2025
e397339
ruff format
Feb 24, 2025
cbd61b8
format
Feb 24, 2025
ebd0e5a
typing in test
Feb 26, 2025
1a99ffb
skipping test ibmq backend
Feb 26, 2025
7130ca0
check for exception in str (ie. qiskit not available) and return repr…
Feb 26, 2025
75c8a76
fix bug in to_qasm3
Feb 26, 2025
8a0fc8a
added reverse_composition param to pattern drawing
Feb 26, 2025
6db71c2
format
Feb 26, 2025
8587ae9
rewrite command to str and unicode
Feb 26, 2025
7502821
rewrite to latex function
Feb 26, 2025
87ac331
pretty print new tests
Feb 26, 2025
7607a86
set default value for reverse_composition arg
Feb 26, 2025
d48d56f
fix tests
Feb 26, 2025
aa79fbb
fix command drawings
Feb 26, 2025
4798719
wrongly inverted s_domain and t_domain in drawing representations
Feb 27, 2025
c76bb38
added latex separator for to_latex + corrected tests writing
Feb 27, 2025
8d115cd
fix bug in to_qasm3 for rotation gates
Feb 27, 2025
bebd826
moved pylatex and qiskit_qasm dependencies to requirements-extra + ad…
Feb 28, 2025
323348d
format
Feb 28, 2025
5025bbb
rename reverse_composition argument to left_to_right
Feb 28, 2025
f5ea223
fix test to qasm3 import => tests are now running but assertions fail
Feb 28, 2025
4c66845
ruff format
Feb 28, 2025
a1cb2ec
lint
Feb 28, 2025
3e2d34a
removed graphix-perceval from extra dependencies as it doesn't work a…
Feb 28, 2025
80fa7cb
skip circuit draw test is qiskit is not installed as it depends on it
Feb 28, 2025
7b21abe
fix forgotten sys impot to allow check if qiskit module is installed
Feb 28, 2025
3acfdd4
format
Feb 28, 2025
af41507
skip for optional dependencies in transpiler test
Feb 28, 2025
f96e24a
update instruction to qasm for consistency with pyzx + added related …
Feb 28, 2025
b910f99
lint + format
Feb 28, 2025
bc86db5
put subscript and superscript in const
benjvmin93 Mar 3, 2025
655a066
cleaned command pretty print + update tests
benjvmin93 Mar 3, 2025
fa8c41a
changes in pattern.__repr__() method
Mar 5, 2025
6bfa593
repr for commands
Mar 6, 2025
4e1b000
commented test_to_qasm3 as pyzx is broken
Mar 7, 2025
82ccbe3
format
Mar 7, 2025
0749e6d
lint
Mar 7, 2025
51127b4
remove T from to_latex
Mar 7, 2025
51f484f
Merge remote-tracking branch 'upstream/master'
Mar 7, 2025
ffeefce
Merge branch 'master' into pretty-print
Mar 7, 2025
21adfcf
removed T from pretty print methods
Mar 7, 2025
28dc783
fix T.__repr__
Mar 7, 2025
b626d99
lint
Mar 7, 2025
7ce1c9e
skip test if pyzx not installed
Mar 7, 2025
c030f41
FIX typo
Mar 7, 2025
8894a0a
removed graphix ibmq as pip Could not find a version that satisfies t…
Mar 7, 2025
eb63332
try to check windows error latex
Mar 7, 2025
2efa42d
fix unnecessary mode
Mar 7, 2025
681c1b6
removed debug print => Windows ci is not passing due to differences i…
Mar 7, 2025
8c5dd7a
put qiskit.qasm3.loads at file top level since qiskit is in requireme…
Mar 11, 2025
1685543
Merge branch 'master' into pretty-print
benjvmin93 Mar 11, 2025
808cd30
added extra for test + ruff format
Mar 11, 2025
d7dd286
Merge branch 'pretty-print' of github.com:benjvmin93/graphix into pre…
Mar 11, 2025
238ca28
format
Mar 11, 2025
5b05ad4
fix typo for ci
Mar 11, 2025
b01a51d
moved import qiskit with try except since we only use it inside draw
Mar 11, 2025
d192341
skip if pyzx is missing
Mar 12, 2025
49d2502
removed extra deps for mypy checks
Mar 12, 2025
3bbf0ea
issues with poppler version with choco => downloading binary from mai…
Mar 12, 2025
6c79fd2
fix windows path in CI
Mar 12, 2025
b3a82f1
fix bad windows path in CI
Mar 12, 2025
426ca05
reset windows ci + skip if pdftocairo not available despite poppler i…
Mar 12, 2025
af935a8
install poppler dependencies for windows without choco
Mar 14, 2025
aafc366
trying to fix paths for windows ci poppler
Mar 14, 2025
988e9a9
use curl instead of gitclone
Mar 14, 2025
1855c09
trying to fix path
Mar 14, 2025
a5f39c4
trying to fix CI
Mar 14, 2025
102115a
trying to update the PATH right
Mar 14, 2025
9a7e4f4
use expand-archive instead of tar
Mar 14, 2025
3ce71e6
using Invoke-RestMethod instead of downloading curl
Mar 15, 2025
4ccf32a
debug
Mar 15, 2025
521e761
Bump ruff from 0.9.10 to 0.11.0 in the python-packages group
dependabot[bot] Mar 17, 2025
eb31b32
fix angle type to ExpressionOrFloat
benjvmin93 Mar 17, 2025
0f0d7da
ruff format
benjvmin93 Mar 17, 2025
f312c69
skip test if on windows
benjvmin93 Mar 17, 2025
bdd8de8
skip tests requiring pdftocairo if os is windows
benjvmin93 Mar 17, 2025
5859646
fixed ruff errors using dict.fromkeys method
Mar 18, 2025
f9c4de1
Merge branch 'dependabot/pip/python-packages-002828dd18' into pretty-…
Mar 19, 2025
a238143
update repr methods for commands
Apr 4, 2025
b84be0e
improve test for multiple nodes in domains
Apr 4, 2025
1226995
update empty set check to checking length
Apr 4, 2025
4bc4123
add PTH rule for ruff linter + use pathlib.open
Apr 4, 2025
3a55f5e
use reversed function instead of slicing
Apr 4, 2025
2bc73db
update _angle_to_str method for command drawing
benjvmin93 Apr 7, 2025
29ad533
fix typos for fraction in latex representation
benjvmin93 Apr 7, 2025
c2415d2
Merge branch 'master' into pretty-print
benjvmin93 Apr 7, 2025
1cdb082
New argument seq for Pattern constructor, and change repr
benjvmin93 Apr 7, 2025
8314903
Merge branch 'pretty-print' of github.com:benjvmin93/graphix into pre…
benjvmin93 Apr 7, 2025
1708489
fix linter error
benjvmin93 Apr 7, 2025
045bcf4
commented poppler-windows setup in CI
Apr 10, 2025
e379ed2
removed private method mentions
Apr 10, 2025
c32886a
Merge branch 'pretty-print' of github.com:benjvmin93/graphix into pre…
Apr 10, 2025
db1ed3c
suggested changes for reprensenting domain inside S command
benjvmin93 Apr 10, 2025
04850a9
changes in _angle_to_str: change parameters with mode for properly re…
Apr 10, 2025
07d5709
Merge branch 'pretty-print' of github.com:benjvmin93/graphix into pre…
Apr 10, 2025
22ef798
fix angle_to_str + test
Apr 14, 2025
f68356c
added pattern.py to mypy checks
Apr 14, 2025
af091ab
remove pattern and add newly created draw_pattern file for mypy check
Apr 14, 2025
8fe8469
ruff lint + format
Apr 14, 2025
a16f67a
update test drawing pattern + fix inside command for drawing clifford
Apr 15, 2025
dfbe04f
update instruction to_qasm3 function based on Thierry's suggestion
Apr 15, 2025
543dc16
ruff format + linter
Apr 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
workflow_dispatch:

permissions:
contents: read
contents: write
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 that if we get rid of the Windows test for TeX, this change is not needed.


concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -29,6 +29,53 @@ jobs:
with:
python-version: ${{ matrix.python }}

- name: Setup TeX Live
uses: teatimeguest/setup-texlive-action@v3
with:
packages: |
scheme-basic
standalone
xypic
qcircuit

- name: Update and install dependencies on Ubuntu
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install -y poppler-utils

- name: Update and install dependencies on macOS
if: runner.os == 'macOS'
run: |
brew update
brew install poppler

# Installation and setup of poppler for Windows seems not to work.
# Here, we try to install poppler-windows and update PATH environment variable. This process seems to work, as the command `pdftocairo.exe -v` executes as expected.
# Though, when running the tests, pdftocairo still seems not found. Thus, we are skipping latex related tests on Windows OS for now.

# - name: Update and install dependencies on Windows
# if: runner.os == 'Windows'
# # Download latest binary of poppler-windows
# # Update PATH with poppler's binary folder
# run: |
# Write-Host "Downloading Poppler..."
# Invoke-RestMethod -Uri https://github.com/oschwartz10612/poppler-windows/releases/download/v24.08.0-0/Release-24.08.0-0.zip -OutFile .\Release-24.08.0-0.zip
# Expand-Archive -Path .\Release-24.08.0-0.zip -DestinationPath .\
#
# $addPath = (Resolve-Path .\poppler-24.08.0\Library\bin).Path
# $regexAddPath = [regex]::Escape($addPath)
#
# $arrPath = $env:Path -split ';' | Where-Object {$_ -notMatch "^$regexAddPath\\?"}
# $arrPath += $addPath
# $env:Path = -join ($arrPath -join ';')
#
# [System.Environment]::SetEnvironmentVariable('Path', $env:Path, [System.EnvironmentVariableTarget]::User)
#
# $env:Path -split ';'
# pdftocairo.exe -v

- run: python -m pip install --upgrade pip

- name: Setup nox
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/cov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,26 @@ jobs:
with:
python-version: "3.12"

- name: Setup TeX Live
uses: teatimeguest/setup-texlive-action@v3
with:
packages: |
scheme-basic
standalone
xypic
qcircuit

- name: Update and install dependencies
run: |
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install -y poppler-utils

- name: Upgrade pip
run: python -m pip install --upgrade pip

- name: Install graphix with dev deps.
run: pip install .[dev]
run: pip install .[dev,extra]

- name: Run pytest
run: pytest --cov=./graphix --cov-report=xml --cov-report=term
Expand Down
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [Unreleased]

### Added
Expand All @@ -31,6 +30,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

## [0.3.1]

This version brings nice ways to visualize both circuit and patterns.

### Added

- Both `Circuit` and `Pattern` classes now have a `draw` method with an argument corresponding to the format the user wants to visualize the object and that returns the appropriate visualization object.
- `Circuit.draw()` is based on `qiskit.QuantumCircuit.draw()` method that takes a qasm3 circuit as input to generate the `QuantumCircuit` object and call its local `draw` method.
- Added the `Circuit.to_qasm3()` method to generate the appropriate qasm3 representation of a `Circuit` object.
- Added `Circuit.__str__()` method overload that calls `Circuit.draw()` with the default `text` argument.
- `Pattern.draw()` relates on its own, with the 4 following visualization formats: `ascii`, `latex`, `unicode` or `png`, respectively returning `str`, `str`, `str` or `PIL.Image.Image`.
- Added `command_to_latex(Command)`, `command_to_str(Command)`/`Command.__str__()` and `command_to_unicode(Command)` methods to generate the appropriate visualizations of a `Command` object.
- Added `Pattern.to_png()`, `Pattern.to_unicode()`, `Pattern.to_latex()` and `Pattern._str__()` methods.

### Fixed

### Changed

## [0.3.0] - 2025-02-04

### Changed
Expand All @@ -56,6 +73,8 @@ This version introduces several important interface changes, aimed at secure exp
- Added `class Instruction` for the gate network expression in quantum circuit model. Every instruction can be instanciated using this class by passing its name as defined in the Enum `InstructionName`.
- `class graphix.OpenGraph` to transpile between graphix patterns and pyzx graphs.
- `class graphix.pauli.PauliMeasurement` as a new Pauli measurement checks (used in `pattern.perform_pauli_measurements`).
- Now variables, functions, and classes are named based on PEP8.
- `KrausChannel` class now uses `KrausData` class (originally `dict`) to store Kraus operators.

### Fixed

Expand Down
Loading
Loading