py2quantikz


Namepy2quantikz JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/madhavan-raja/py2quantikz
SummaryConverts Quantum Circuit Code to quantikz Diagrams
upload_time2023-10-20 18:01:28
maintainer
docs_urlNone
authorMadhavan Raja
requires_python>=3.6
licenseMIT
keywords python tikz quantikz latex quantum
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # py2quantikz

A library to convert Quantum code to LaTeX quantikz circuit diagrams.

## Installation

Install using `pip`:

```shell
pip install py2quantikz
```

## Usage

Initialize a circuit using `QuantumCircuit()` and pass in the number of qubits in the system.

Use the `apply()` method of `QuantumCircuit` to pass in a `GateApplication` or a list of `GateApplication` to it.

Get the circuit diagram code with the `quantikz()` method of `QuantumCircuit`.

```python
from py2quantikz.py2quantikz import QuantumCircuit, GateApplication as ga
import py2quantikz.gates as qg

circuit = QuantumCircuit(4)

circuit.apply([ga(qg.H, 0), ga(qg.H, 2)])
circuit.apply([ga(qg.X, 1, 0), ga(qg.X, 3, 2)])
circuit.apply([ga(qg.M, 0), ga(qg.M, 2)])

quantikz_repr = circuit.quantikz()
print(quantikz_repr)
```

This will result in

```latex
Q_0 & \gate{H} & \ctrl{1} & \meter{} & \\
Q_1 &          & \gate{X} &          & \\
Q_2 & \gate{H} & \ctrl{1} & \meter{} & \\
Q_3 &          & \gate{X} &          & \\
```

The `quantikz()` method accepts a separation parameter `sep`, which is used to separate the individual circuit elements.

```python
circuit.quantikz(sep="&[0.5em]")
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/madhavan-raja/py2quantikz",
    "name": "py2quantikz",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "python,tikz,quantikz,latex,quantum",
    "author": "Madhavan Raja",
    "author_email": "madhavanraja99@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/88/5b/67df00d862830245e27787b12d62f7dc6b0a116226e909c07660ac3f21d7/py2quantikz-0.0.2.tar.gz",
    "platform": null,
    "description": "# py2quantikz\n\nA library to convert Quantum code to LaTeX quantikz circuit diagrams.\n\n## Installation\n\nInstall using `pip`:\n\n```shell\npip install py2quantikz\n```\n\n## Usage\n\nInitialize a circuit using `QuantumCircuit()` and pass in the number of qubits in the system.\n\nUse the `apply()` method of `QuantumCircuit` to pass in a `GateApplication` or a list of `GateApplication` to it.\n\nGet the circuit diagram code with the `quantikz()` method of `QuantumCircuit`.\n\n```python\nfrom py2quantikz.py2quantikz import QuantumCircuit, GateApplication as ga\nimport py2quantikz.gates as qg\n\ncircuit = QuantumCircuit(4)\n\ncircuit.apply([ga(qg.H, 0), ga(qg.H, 2)])\ncircuit.apply([ga(qg.X, 1, 0), ga(qg.X, 3, 2)])\ncircuit.apply([ga(qg.M, 0), ga(qg.M, 2)])\n\nquantikz_repr = circuit.quantikz()\nprint(quantikz_repr)\n```\n\nThis will result in\n\n```latex\nQ_0 & \\gate{H} & \\ctrl{1} & \\meter{} & \\\\\nQ_1 &          & \\gate{X} &          & \\\\\nQ_2 & \\gate{H} & \\ctrl{1} & \\meter{} & \\\\\nQ_3 &          & \\gate{X} &          & \\\\\n```\n\nThe `quantikz()` method accepts a separation parameter `sep`, which is used to separate the individual circuit elements.\n\n```python\ncircuit.quantikz(sep=\"&[0.5em]\")\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Converts Quantum Circuit Code to quantikz Diagrams",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/madhavan-raja/py2quantikz"
    },
    "split_keywords": [
        "python",
        "tikz",
        "quantikz",
        "latex",
        "quantum"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "885b67df00d862830245e27787b12d62f7dc6b0a116226e909c07660ac3f21d7",
                "md5": "8783b1403bf50d476de37f30cdeaa6dc",
                "sha256": "fa76a11a419b3bd113c7d94ebbf35c4bba9ae493da94d4ebabc65a58225e315a"
            },
            "downloads": -1,
            "filename": "py2quantikz-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "8783b1403bf50d476de37f30cdeaa6dc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 2404,
            "upload_time": "2023-10-20T18:01:28",
            "upload_time_iso_8601": "2023-10-20T18:01:28.703288Z",
            "url": "https://files.pythonhosted.org/packages/88/5b/67df00d862830245e27787b12d62f7dc6b0a116226e909c07660ac3f21d7/py2quantikz-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-20 18:01:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "madhavan-raja",
    "github_project": "py2quantikz",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "py2quantikz"
}
        
Elapsed time: 0.15210s