Skip to main content

Highly Customizable Quantum Circuit SVG Visualizer

Project description

Quantum QuirkVis 🙃

A python package that draws quantum circuits written in qasm/OpenQASM 3.0 and outputs as SVG with a strong focus on personalization.

Features

  • SVG output
  • Theming engine (JSON)
  • Personalization (night mode, custom colors)
  • Gate symbol substitutions (emojis, icons, animations)
  • Awesome "dial" for parametrized gates
  • Animations and other CSS filters
  • Lightweight

Themes

Default

Default Theme

Night

Night Theme

Matrix

Matrix Theme

Emoji

Emoji Theme

Installation

pip install quirkvis

Usage

from quantum_quirkvis import draw

qasm_str = """
OPENQASM 3.0;
qubit[2] q;
h q[0];
cx q[0], q[1];
"""

draw(qasm_str, theme="matrix", filename="path/to/file.svg")

# or

svg = draw(qasm_str, theme="matrix")

Personalization

Check the themes json files to see how much you can customize, you can customize anything!

Then create your own theme, you don't need to overwrite all the file, you only have to change the values of interest, the rest if defaulted.

  • mytheme.json
{
    "name": "default",
    "styles": {
        "background": "#777777",
    }
}

then simply

draw(qasm_str, theme="mytheme.json")

You can also use the cli provided which exposes the command qasmvis

qasmvis ghz.qasm -t matrix -o ghz.svg

or

qasmvis ghz.qasm -t matrix > ghz.svg

or

cat ghz.qasm | qasmvis -t night > ghz.svg

Libraries

The current package just requires pyqasm to parse the qasm files or string into the AST that is processed to create SVG with the selected theme.

License

MIT

Limitations

Currently the library "unrolls" the circuit, therefore complex or custom gates (like CY, Toffoli, CSWAP, etc) are drawn as their primitives.

U-n gates are not yet supported

unitaryDESIGN

This repo is currently running for a bounty on unitaryDESIGN hackathon

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quirkvis-0.1.1.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quirkvis-0.1.1-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file quirkvis-0.1.1.tar.gz.

File metadata

  • Download URL: quirkvis-0.1.1.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for quirkvis-0.1.1.tar.gz
Algorithm Hash digest
SHA256 afcf609002075c68f0fc21f3c581a90d8fb875eafb69a85f5bd4d6f0e7acd4b9
MD5 749b6cc5bec6b2e9e36b4b8156fd656c
BLAKE2b-256 a0e7483f69e80bbcada4d23486082344a3c2703d306879edfa295b7cc3b6ff12

See more details on using hashes here.

Provenance

The following attestation bundles were made for quirkvis-0.1.1.tar.gz:

Publisher: release.yml on ljcamargo/quantum_quirkvis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quirkvis-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: quirkvis-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for quirkvis-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 92096afe333849f4f68e27cdf69cbb006f71c67c15be19e7005c24b1746f360c
MD5 684d7540eb8f497323cfe0fc27e098db
BLAKE2b-256 6366be37c0fca108abc398c737de3cdc7bcf0892ba1fb6535904dad8da50c94f

See more details on using hashes here.

Provenance

The following attestation bundles were made for quirkvis-0.1.1-py3-none-any.whl:

Publisher: release.yml on ljcamargo/quantum_quirkvis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page