VOOZH about

URL: https://pypi.org/project/qulacsvis/

โ‡ฑ qulacsvis ยท PyPI


Skip to main content

qulacsvis 0.7.6

pip install qulacsvis

Latest release

Released:

visualizers for qulacs

Navigation

Verified details

These details have been verified by PyPI
Maintainers
๐Ÿ‘ Avatar for hyuyukun from gravatar.com
hyuyukun

Unverified details

These details have not been verified by PyPI
Project links
Meta
  • License: MIT License (MIT)
  • Author: Qulacs-Osaka
  • Requires: Python >=3.9

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. 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.

fromqulacsimport QuantumCircuit
fromqulacsvisimport 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".

importmatplotlib.pyplotasplt

circuit_drawer(circuit, "mpl")
plt.show()

๐Ÿ‘ 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={-2pt 5pt 5pt -7pt}]{standalone}
\usepackage[braket, qm]{qcircuit}
\usepackage{graphicx}

\begin{document}
 \Qcircuit @C=1.0em @R=0.7em @!R{ \\
 \nghost{ q_{0} : } & \lstick{ q_{0} : } & \gate{X} & \multigate{1}{DeM} & \targ & \qw & \qw\\
 \nghost{ q_{1} : } & \lstick{ q_{1} : } & \gate{Y} & \ghost{DeM} & \qw & \qw & \qw\\
 \nghost{ q_{2} : } & \lstick{ q_{2} : } & \gate{Z} & \qw & \ctrl{-2} & \gate{X} & \qw\\
 }
\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.

Save image to file

You can save the images you draw with matplotlib and LaTeX to a file.

# matplotlib
circuit_drawer(circuit, "mpl", filename="output.png")

# latex
circuit_drawer(circuit, "latex", filename="output.png")

License

MIT License

Contributors

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

Project details

Verified details

These details have been verified by PyPI
Maintainers
๐Ÿ‘ Avatar for hyuyukun from gravatar.com
hyuyukun

Unverified details

These details have not been verified by PyPI
Project links
Meta
  • License: MIT License (MIT)
  • Author: Qulacs-Osaka
  • Requires: Python >=3.9

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.7.6.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

Filter files by name, interpreter, ABI, and platform.

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

Copy a direct link to the current filters

qulacsvis-0.7.6-py3-none-any.whl (25.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: qulacsvis-0.7.6.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.12.11 Linux/6.8.0-1031-azure

File hashes

Hashes for qulacsvis-0.7.6.tar.gz
Algorithm Hash digest
SHA256 344c0f9604207a5b4b513863eb358e20439a9275b037ae1d58ee255380fe66d6
MD5 0bf036483ecb0ddd434baa8500d3e008
BLAKE2b-256 f63fc641b78ba4d8b32aed2fa95c76ef3e54398668baaf642f296f0337f3c92a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qulacsvis-0.7.6-py3-none-any.whl
  • Upload date:
  • Size: 25.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.12.11 Linux/6.8.0-1031-azure

File hashes

Hashes for qulacsvis-0.7.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e2a1bf1143781c4efc9bf002e16487bc9910937905679418a50d0c3b124d2204
MD5 5ced86827bcd63cb175489c9691d3bbd
BLAKE2b-256 9199bcd8d88645ccca567bd8fbf197e831b8f28773d6c370a6aa90e3e9525301

See more details on using hashes here.

Supported by

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