Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adgt/pyquirk
A Python widget for Quirk to be used in Jupyter notebooks, JupyterLab, and the IPython kernel.
https://github.com/adgt/pyquirk
quantum-computing
Last synced: 2 months ago
JSON representation
A Python widget for Quirk to be used in Jupyter notebooks, JupyterLab, and the IPython kernel.
- Host: GitHub
- URL: https://github.com/adgt/pyquirk
- Owner: adgt
- License: apache-2.0
- Created: 2020-11-18T05:13:10.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-19T21:35:40.000Z (over 2 years ago)
- Last Synced: 2024-10-12T11:21:54.133Z (2 months ago)
- Topics: quantum-computing
- Language: HTML
- Homepage:
- Size: 1.03 MB
- Stars: 24
- Watchers: 6
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pyQuirk
[![pypi](https://img.shields.io/pypi/v/pyQuirk.svg)](https://pypi.org/project/pyQuirk/)A Python [widget](https://github.com/jupyter-widgets/ipywidgets) for [Quirk](https://github.com/Strilanc/Quirk) to be used in Jupyter notebooks, JupyterLab, and the IPython kernel.
![Example](example.gif)
## Getting Started
### InstallationTo install use pip (JupyterLab 3 recommended):
$ pip install pyQuirk
If you are wanting to use this with JupyterLab 2 or a classical Jupyter notebook install (i.e. not the one included with JupyterLab 3), then you can try following the [development install instructions](#development) below, but YMMV.
### Example
Take a look at [example.ipynb](example.ipynb) for a simple example.
Otherwise, you can simply run:
```python
from pyQuirk import Quirk
quirk = Quirk()
quirk
```### API
Quirk()
- `width`: display width of the widget
- `height`: display height of the widget
- `scale`: scale of the inner Quirk display (default 0.5)
- `value`: circuit in Quirk format
- `circuit_qasm`: read-only property to get the qasm of the current circuit
- `update_circuit(circuit)`: convenience function for passing a Qiskit circuit
- `update_from_qasm(qasm)`: replace the current circuit with qasm (not all gates supported, currently)## Development
For a development installation (requires [Node.js](https://nodejs.org) and [Yarn version 1](https://classic.yarnpkg.com/)),
$ git clone https://github.com/adgt/pyQuirk.git
$ cd pyQuirk
$ pip install -e .If you are working with Jupyter notebook, then run these commands:
$ jupyter nbextension install --py --symlink --overwrite --sys-prefix pyQuirk
$ jupyter nbextension enable --py --sys-prefix pyQuirkIf you are working with JupyterLab 3, run the command:
$ jupyter labextension develop --overwrite pyQuirk
Then you need to rebuild the JS when you make a code change:
$ cd js
$ yarn run buildYou then need to refresh the JupyterLab page when your javascript changes.
#### Project repository created with the [widget-cookiecutter](https://github.com/jupyter-widgets/widget-cookiecutter) template