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

Add a full-featured serializer from a qiskit.QuantumCircuit to a quantum-viz.js JSON #44

Merged
merged 109 commits into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from 95 commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
5d11ab2
Add qiskit python parser. (#35)
atching Sep 14, 2021
92e05af
Move qiskit_parser contents to quantum_viz
jond01 Nov 1, 2021
a8aa6c1
Change qiskit_parser functions interface
jond01 Oct 15, 2021
39f16fa
Add a basic `QiskitCircuitParser` class
jond01 Oct 27, 2021
4b7ca4b
Add a utils module to display the parser result
jond01 Oct 27, 2021
0617867
Add `parse_operation` method
jond01 Oct 28, 2021
0baddd0
Support instruction params through displayArgs
jond01 Oct 28, 2021
63c9c76
Support controlled gates
jond01 Oct 28, 2021
53795ec
Small fixes in measurement operation
jond01 Oct 28, 2021
01da871
Uppercase X and SWAP to benefit from gate visualizations
jond01 Oct 28, 2021
57c7e2d
Capitalize or uppercase some gate names
jond01 Oct 28, 2021
ef416c9
Replace the old code with `QiskitCircuitParser`
jond01 Oct 28, 2021
350f84e
Add `RegisterType` and `ConditionalRender` int enums
jond01 Oct 28, 2021
7c310db
Support measurements
jond01 Oct 28, 2021
8616373
Support children operations through naive recursion
jond01 Oct 28, 2021
6377e15
Uppercase the U gate
jond01 Oct 28, 2021
96d7657
Update the example to a single swap gate
jond01 Oct 28, 2021
b266d24
Revert "Update the example to a single swap gate"
jond01 Oct 28, 2021
e2cae1a
Support recursion with updated sub qargs and cargs
jond01 Oct 28, 2021
33861f9
Remove unused imports
jond01 Oct 28, 2021
c886cbf
Update uppercase list
jond01 Oct 28, 2021
539d8c3
Set isAdjoint to true for "dg" qiskit's gates
jond01 Oct 28, 2021
eebe1d4
Revert last commit - this is not the intent of isAdjoint
jond01 Oct 28, 2021
151d706
Fix the args of the children operations
jond01 Oct 28, 2021
4e269e4
Add new rules for gate naming
jond01 Oct 28, 2021
f92daa1
Add reset instruction to `NotImplementedError` block
jond01 Oct 28, 2021
61d7c90
Support reset instruction - condition X gate on measurement result
jond01 Oct 28, 2021
a1b1439
Use `_get_qubit_list_def` method for targets
jond01 Oct 28, 2021
6f70dfa
Add conditioned instruction to not implemented block
jond01 Oct 28, 2021
ff3a655
Add kwargs propagation to all relevant functions
jond01 Oct 29, 2021
19234fe
Add `max_depth` parameter to `QiskitCircuitParser`
jond01 Oct 29, 2021
4427e8a
Update type hint
jond01 Oct 29, 2021
ea994eb
Add a todo - avoid using qubit's and clbit's index
jond01 Oct 29, 2021
1c7f9ce
Add classical conditioning support
jond01 Oct 29, 2021
9457fc9
Remove adding the ancillas to the qubits
jond01 Oct 29, 2021
a467cd6
Avoid unnecessary definitions
jond01 Oct 29, 2021
a415160
Use bit mappers instead of the deprecated `index` property
jond01 Oct 29, 2021
47ed29e
Move gate renaming logic to a class method
jond01 Oct 29, 2021
6249e92
Comment about the reset children
jond01 Oct 29, 2021
e57c9a0
Move params addition ("displayArgs") to a method
jond01 Oct 29, 2021
50f93e7
Move measurement addition to a method
jond01 Oct 29, 2021
27312df
Move controlled gate addition to a method
jond01 Oct 29, 2021
fa432c2
Move children addition to a method
jond01 Oct 29, 2021
b18a158
Remove the None option from depth argument
jond01 Oct 29, 2021
3a719fa
Add `show_barrier` param and type hints to existing params
jond01 Oct 29, 2021
55d24fc
Use `skip_barriers` instead of `show_barrier`
jond01 Oct 30, 2021
4e295e8
Support barriers
jond01 Oct 30, 2021
a060bbc
Add filename, style, and version args to display function
jond01 Oct 30, 2021
40066d0
Add some todo comments to parser
jond01 Oct 30, 2021
581a4d9
Remove a resolved todo - stay with the top circuit
jond01 Oct 30, 2021
9c70bd9
Make all the parser's methods private
jond01 Oct 30, 2021
3d04956
Add operations property to parser
jond01 Oct 30, 2021
a5874c4
Remove children key if empty
jond01 Oct 30, 2021
4ab5266
Support symbolic params
jond01 Oct 31, 2021
19b603e
Use `QuantumCircuit` without the `qiskit.` prefix
jond01 Oct 31, 2021
deef2bb
Remove the unused operations property deleter
jond01 Oct 31, 2021
7e1726b
Format complex params the same way as floats
jond01 Oct 31, 2021
b04cdcf
Use qubits property
jond01 Oct 31, 2021
e110e88
Add a todo about ParameterExpression
jond01 Oct 31, 2021
802decc
Use `get` instead of using the "children" key directly
jond01 Oct 31, 2021
fa4511e
Rename `_check_children` to `_remove_empty_children`
jond01 Oct 31, 2021
9ddb4f5
Change depth to recursion depth
jond01 Oct 31, 2021
fb76c8b
Minimize the access to `op_dict["gate"]` in `_rename_gate`
jond01 Oct 31, 2021
d4750b5
Add noqa to `import qiskit`
jond01 Oct 31, 2021
578e280
Define the instruction type names in a single dictionary
jond01 Nov 1, 2021
8361719
Remove the `_remove_empty_children` method
jond01 Nov 1, 2021
a57bb34
Comment about `_update_condition` position
jond01 Nov 1, 2021
66b0d34
Store `q_id` and not `qubit` in `_clbit2id`
jond01 Nov 1, 2021
47276b6
Add tests for empty circuits
jond01 Nov 2, 2021
229c91d
Use the value of `ConditionalRender` enums
jond01 Nov 3, 2021
78c542b
Rename `_param_formatter` to `_format_param`
jond01 Nov 3, 2021
1d28c6e
Remove a comment about parameter expression
jond01 Nov 3, 2021
b56e04c
Add more tests
jond01 Nov 4, 2021
36de176
Remove tested parts from utils
jond01 Nov 4, 2021
fb00b57
Add pre-commit changes
jond01 Nov 4, 2021
b48b751
Lint
jond01 Nov 9, 2021
03863e9
Add `qiskit-terra` as a dev-dependency and "qiskit" extras
jond01 Nov 9, 2021
862f05b
Poetry update
jond01 Nov 9, 2021
187f48f
add qiskit dependency
Nov 17, 2021
a4596bc
add dispatch trigger for workflow
Nov 17, 2021
aeb7978
change package name to fix typeguard issue
Nov 17, 2021
cf8182a
rename conftest.py to test_qiskit_gen_results, use fixtures
Nov 17, 2021
88ca08e
add display example script
Nov 17, 2021
68b85d6
refactor tests
Nov 17, 2021
9a9e77e
pre-commit changes
Nov 18, 2021
ea68d33
pre commit changes
Nov 18, 2021
9e824c2
lower to 90% coverage requirement
Nov 18, 2021
25f4d14
Merge branch 'main' into feature/qiskit
jond01 Nov 19, 2021
fd1e7d5
Fix the `qiskit` extras in `pyproject.toml`
jond01 Nov 23, 2021
1690457
Install `qiskit` extras in nox tests session
jond01 Nov 23, 2021
4cc82d3
Install `qiskit` extras in nox typeguard sessions
jond01 Nov 23, 2021
9a15bb6
Use `TYPE_CHECKING ` in `utils.py`
jond01 Nov 23, 2021
f142710
Accept qviz dicts in display
jond01 Nov 23, 2021
92c21cb
Accept dicts in display without `qiskit`
jond01 Nov 23, 2021
b850d9d
Do not require a specific minor of `qiskit`
jond01 Nov 24, 2021
683ea09
Add a copyright notice
jond01 Dec 6, 2021
2c47927
Add a copyright notice
jond01 Dec 6, 2021
3a32b10
Add a copyright notice
jond01 Dec 6, 2021
2f4c771
Qiskit sample notebook
anpaz Dec 3, 2021
01174ad
Some proofreading of the notebook
jond01 Dec 6, 2021
b663f54
Reorder imports
jond01 Dec 27, 2021
bfb53b0
Fix the string in the Widget test
jond01 Dec 27, 2021
6b239cb
Applying feedback
anpaz May 18, 2022
8278f1e
Merge pull request #7 from microsoft/pr/jond01/44
jond01 May 20, 2022
159c426
Merge branch 'main' into feature/qiskit
jond01 May 20, 2022
b61ef36
Fix qiskit-terra dependency and add style option
jond01 May 20, 2022
53b41a1
Fix a missing import and some mypy errors
jond01 May 20, 2022
883f2b5
Fix mypy and arrange utils
jond01 May 20, 2022
dd1d0e2
Fix some flake8 errors
jond01 May 20, 2022
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
339 changes: 339 additions & 0 deletions quantum-viz/examples/Qiskit.ipynb

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions quantum-viz/examples/display_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from qiskit.circuit.random import random_circuit
jond01 marked this conversation as resolved.
Show resolved Hide resolved
from qiskit.circuit.reset import Reset
from quantum_viz.utils import display

qc = random_circuit(4, 5, measure=False, reset=True, conditional=False)
qc.barrier()
qc.rccx(0, 3, 2)
qc.sxdg(1)
qc.append(Reset(), [1])

print(qc.draw())
display(qc, skip_barriers=False, style="BlackAndWhite", version="1.0.2")
6 changes: 3 additions & 3 deletions quantum-viz/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
raise SystemExit(dedent(message))


package = "quantum_viz"
package = "quantum-viz"
python_versions = ["3.9", "3.8", "3.7"]
nox.needs_version = ">= 2021.6.6"
nox.options.sessions = (
Expand Down Expand Up @@ -136,7 +136,7 @@ def mypy(session: Session) -> None:
@session(python=python_versions)
def tests(session: Session) -> None:
"""Run the test suite."""
session.install(".")
session.install(".[qiskit]")
session.install("coverage[toml]", "pytest", "pygments")
try:
session.run("coverage", "run", "--parallel", "-m", "pytest", *session.posargs)
Expand All @@ -161,7 +161,7 @@ def coverage(session: Session) -> None:
@session(python=python_versions)
def typeguard(session: Session) -> None:
"""Runtime type checking using Typeguard."""
session.install(".")
session.install(".[qiskit]")
session.install("pytest", "typeguard", "pygments")
session.run("pytest", f"--typeguard-packages={package}", *session.posargs)

Expand Down
Loading