Skip to main content

pyqubits

A Python module for quantum computing simulations.

Setup

$ git clone https://github.com/tombch/pyqubits.git
$ cd pyqubits/
$ conda env create -f environment.yml
$ conda activate pyqubits
$ pip install .

Usage

Creating a QuantumState

>>> from pyqubits import QuantumState
>>> s = QuantumState(3)
>>> t = QuantumState.from_bits('00')

Viewing a QuantumState

>>> s
QuantumState([-0.29615118+0.50152956j,  0.37355584-0.06041027j,
               0.40094705-0.13785654j, -0.17540328-0.25628919j,
              -0.26399075+0.28541768j,  0.11632225-0.12028472j,
               0.08627474-0.14452522j,  0.04189382+0.17920989j])
>>> s.vector
array([-0.29615118+0.50152956j,  0.37355584-0.06041027j,
        0.40094705-0.13785654j, -0.17540328-0.25628919j,
       -0.26399075+0.28541768j,  0.11632225-0.12028472j,
        0.08627474-0.14452522j,  0.04189382+0.17920989j])
>>> print(s)
= (- 0.29615 + 0.50153j) |000> + (  0.37356 - 0.06041j) |001> 
+ (  0.40095 - 0.13786j) |010> + ( - 0.1754 - 0.25629j) |011> 
+ (- 0.26399 + 0.28542j) |100> + (  0.11632 - 0.12028j) |101> 
+ (  0.08627 - 0.14453j) |110> + (  0.04189 + 0.17921j) |111> 
>>> print(s.circuit)
1---
    
2---
    
3---
>>> print(s.dist)
000     0.34    |=================
001     0.14    |=======
010     0.18    |=========
011     0.1     |=====
100     0.15    |========
101     0.03    |=
110     0.03    |=
111     0.03    |==
>>> t
QuantumState([1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j])
>>> t.vector
array([1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j])
>>> print(t)
= (1 + 0j) |00> 
>>> print(t.circuit)
1---
    
2---
>>> print(t.dist)
00      1.0     |==================================================
01      0.0     |
10      0.0     |
11      0.0     |

Manipulating a QuantumState

>>> t.H(1)
QuantumState([0.70710678+0.j, 0.        +0.j, 0.70710678+0.j, 0.        +0.j])
>>> t.CNOT(1, 2)
QuantumState([0.70710678+0.j, 0.        +0.j, 0.        +0.j, 0.70710678+0.j])
>>> print(t)
= (0.70711 + 0j) |00> + (0.70711 + 0j) |11> 
>>> print(t.circuit)
1---H---O---
        |   
2-------X---
>>> print(t.dist)
00      0.5     |=========================
01      0.0     |
10      0.0     |
11      0.5     |=========================
>>> t.measure(1)
QuantumState([1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j])
>>> result = t.bit
>>> result
0
>>> print(t)
= (1 + 0j) |00>

Metadata

Release files for pyqubits 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyqubits 0.2.1
File Size Uploaded Provenance Actions
pyqubits-0.2.1.tar.gz 10.1 kB Without provenance Details for pyqubits-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyqubits 0.2.1
File Interpreter ABI Platform Actions
pyqubits-0.2.1-py3-none-any.whl Python 3 none any Details for pyqubits-0.2.1-py3-none-any.whl

Total release size: 19.6 kB

Release files / pyqubits-0.2.1.tar.gz

Download URL pyqubits-0.2.1.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3750e238b79ba6a32e41517f027002681f4bacff45160decfbb0252895f6f28f
BLAKE2b-256 checksum
How to use checksums
fe30b3075e01f2f5c69836311b72657e71a1a625eef152a65439f7c13463452f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / pyqubits-0.2.1-py3-none-any.whl

Download URL pyqubits-0.2.1-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1cc9813d0bd1e2818795a85a788fbae356281350cf3b42de4003938631f8ca6b
BLAKE2b-256 checksum
How to use checksums
137810cdd20eeefbb4f5782915e777eee7087bec45e66df32e9a7c08c697dc33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Security for pyqubits 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page