Skip to main content

A visualisation tool for quantum information

Project description

CubeIt

CubeIt is a lightweight quantum playground for n-qubit registers. Universal gate set and utilities for visualisation and testing.

Features

  • N-Qubit Registers: Create registers of any size with quantumregister(n).
  • Universal Gate Set: (h(), s(), t(), cnot(), …) (qr.h(i), qr.cnot(control, target)).
  • Measurement: get_state() prints amplitudes, measure() collapses and returns classical outcomes.
  • Utility Modules: Measurement statistics, Bell-state builders, fidelity checks, and more under cubeit.visualization.

Installation

Install the package

pip install cubeit

Or clone the repository and download the requirements

pip install -r requirements.txt

Quick Start

from cubeit import quantumregister, get_state, measure

# 1) Create a 4-qubit register (|0000⟩)
qr = quantumregister(4)

# 2) Build a circuit
qr.h(0)          # Hadamard on qubit 0
qr.cnot(0, 1)    # Entangle qubit 0 and 1
qr.rx(2, 0.5)    # Rotate qubit 2 around X by 0.5 radians
qr.cz(1, 3)      # Controlled-Z between qubit 1 and 3

# 3) Inspect the statevector (pretty printed)
get_state(qr)

# 4) Measure – collapses the state and returns a bitstring
result = measure(qr)
print("Measurement:", result)

Gates at a Glance

Helper Description
qr.h(i) Hadamard on qubit i
qr.x(i), qr.y(i), qr.z(i) Pauli gates
qr.s(i), qr.t(i) Phase / π/8 gates
qr.rx(i, θ), qr.ry(i, θ), qr.rz(i, θ) Rotations
qr.cnot(control, target) Controlled-NOT
qr.cz(control, target) Controlled-Z
qr.cphase(control, target, φ) Controlled-phase
qr.swap(a, b) Swap two qubits

Measurement & Probabilities

from cubeit import quantumregister, get_state, measure
from cubeit.visualization import print_probabilities

qr = quantumregister(2).h(0).cnot(0, 1)

print_probabilities(qr)
# Measurement Probabilities:
#   |00⟩: 0.5000 (50.00%)
#   |11⟩: 0.5000 (50.00%)

measure(qr)  # collapses the register and prints the classical outcome

Bell States & Visualisation

from cubeit.visualization import create_bell_state, print_state, print_measurement_stats

bell = create_bell_state("phi_plus")
print_state(bell)                 # 0.707|00⟩ + 0.707|11⟩
print_measurement_stats(bell)     # Monte-Carlo sampling

quantumregister

Factory returning an instance of the internal _QuantumRegister. Methods:

  • apply_gate(matrix) / apply_single_qubit_gate(matrix, qubit)
  • measure() & measure_qubit(qubit)
  • get_state() → returns a QuantumState
  • get_probabilities()np.ndarray
  • Fluent helpers: h, x, y, z, s, t, phase, rx, ry, rz, cnot, cz, cphase, swap

Examples

Example 1: Creating a Bell State

from cubeit import quantumregister

qr = quantumregister(2)
qr.h(0).cnot(0, 1)
print(qr)
# QuantumRegister(2 qubits):
#   0.707|00⟩ + 0.707|11⟩

Example 2: Measurement Statistics

from cubeit import quantumregister
from cubeit.visualization import print_measurement_stats

qr = quantumregister(2).h(0).cnot(0, 1)

print_measurement_stats(qr, num_samples=1000)

Requirements

  • Python >= 3.8
  • NumPy >= 1.20.0

License

See LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

cubeit-0.0.2.tar.gz (27.2 kB view details)

Uploaded Source

Built Distribution

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

cubeit-0.0.2-py3-none-any.whl (31.6 kB view details)

Uploaded Python 3

File details

Details for the file cubeit-0.0.2.tar.gz.

File metadata

  • Download URL: cubeit-0.0.2.tar.gz
  • Upload date:
  • Size: 27.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for cubeit-0.0.2.tar.gz
Algorithm Hash digest
SHA256 815e0695632a8639ae57e5e5ddf6eea7389e7137a52f2fc0ea994f04f51d7ee2
MD5 887868738b0f9d4f6308d0ddf7febe6e
BLAKE2b-256 622b0a14e90695d39d21a4be8e821786b38e35a690ab29bb27dae773aa9efa63

See more details on using hashes here.

File details

Details for the file cubeit-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: cubeit-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 31.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for cubeit-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 40b56dae380d43f2687b276d22eedc0ebb0b4006f4660c1b45ee2f928b3d9454
MD5 4ae648adbed7c885ed09ead962834cce
BLAKE2b-256 79c0703bfa27aed2dbec9607915697e8eece60848beb8d83e9663356b6bd6b8f

See more details on using hashes here.

Supported by

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