Skip to main content

visualizers for qulacs

Project description

qulacs-visualizer

CI Build and Deploy Documentation PyPI version MIT

qulacs-visualizer is a quantum circuit drawing library for qulacs. This library only supports Python. Not available in C/C++.

qulacs-visualizer supports the following methods.

Quick Install

Install using pip from PyPI:

pip install qulacsvis

Example

For more information, see the documentation of the circuit_drawer() function. The documentation describes the other options available.

Text-Based Drawing

In text-based mode, draws the circuit as ASCII art. This mode is the default behavior.

from qulacs import QuantumCircuit
from qulacsvis import circuit_drawer

# Build a quantum circuit
circuit = QuantumCircuit(3)
circuit.add_X_gate(0)
circuit.add_Y_gate(1)
circuit.add_Z_gate(2)
circuit.add_dense_matrix_gate(
    [0, 1], [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]]
)
circuit.add_CNOT_gate(2, 0)
circuit.add_X_gate(2)

# Draw a quantum circuit
circuit_drawer(circuit)
   ___     ___     ___
  | X |   |DeM|   |CX |
--|   |---|   |---|   |----------
  |___|   |   |   |___|
   ___    |   |     |
  | Y |   |   |     |
--|   |---|   |-----|------------
  |___|   |___|     |
   ___              |      ___
  | Z |             |     | X |
--|   |-------------●-----|   |--
  |___|                   |___|

Matplotlib Drawing

To use another drawing method, you can specify it by setting a value to the output_method argument of the circuit_drawer() function. For matplotlib drawing, set output_method="mpl".

circuit_drawer(circuit, "mpl")

circuit_matplotlib_drawing.png

LaTeX Drawing

For LaTeX drawing, set output_method="latex".

circuit_drawer(circuit, "latex")

circuit_latex_drawing.png

If you want to output LaTeX code, set output_method="latex_source".

print(circuit_drawer(circuit, "latex_source"))
\documentclass[border=2px]{standalone}
\usepackage[braket, qm]{qcircuit}
\usepackage{graphicx}

\begin{document}
    \scalebox{1.0}{
    \Qcircuit @C=1.0em @R=0.2em @!R { \\
        \nghost{ {q}_{0} : } & \lstick{ {q}_{0} :  } & \gate{X} & \multigate{1}{DeM} & \targ & \qw \\
        \nghost{ {q}_{1} : } & \lstick{ {q}_{1} :  } & \gate{Y} & \ghost{DeM} & \qw & \qw \\
        \nghost{ {q}_{2} : } & \lstick{ {q}_{2} :  } & \gate{Z} & \qw & \ctrl{-2} & \gate{X} \\
    }}
\end{document}

Requirement

If you want to use LaTeX Drawing, you need to have a local environment where you can run LaTeX (pdflatex). You will also need the qcircuit package. TeX Live and MiKTeX have the qcircuit package installed by default.

License

MIT License

Contributors

We use qqcd for text-based drawing, a drawing library developed by @mf-22. Thank you.

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

qulacsvis-0.2.2.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

qulacsvis-0.2.2-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

Details for the file qulacsvis-0.2.2.tar.gz.

File metadata

  • Download URL: qulacsvis-0.2.2.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.12 Linux/5.13.0-1021-azure

File hashes

Hashes for qulacsvis-0.2.2.tar.gz
Algorithm Hash digest
SHA256 d5f00f1488b126dbd93e8d8308aab053859a62a0ee66dc13bed334c36ac1cfc0
MD5 7e0569d2781e430f9ff7656a580e25dc
BLAKE2b-256 5bd59c03e60649dbe752e7b69026dfc29054b638ea7f1aa01e1a2a615ceeff20

See more details on using hashes here.

File details

Details for the file qulacsvis-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: qulacsvis-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 22.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.12 Linux/5.13.0-1021-azure

File hashes

Hashes for qulacsvis-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 61307e20b33bb1f452b1324f5b3e2c218c22b0066d2cd25feb7bdfcb00d18e5f
MD5 375bd814ea9c0f81aef395ee412a9f7c
BLAKE2b-256 2098061a7adeeb27bde0b65ad27cc178b9654a6a743f4b3337f2fddac8abbe04

See more details on using hashes here.

Supported by

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