Skip to main content

A visualisation tool for quantum information

Project description

CubeIt

CubeIt is a lightweight quantum playground for 2-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 2-qubit register (|00⟩)
qr = quantumregister(2)

# 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 1 around X by 0.5 radians
qr.cz(0, 1)      # Controlled-Z between qubit 0 and 1

# 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.3.tar.gz (28.3 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.3-py3-none-any.whl (32.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cubeit-0.0.3.tar.gz
  • Upload date:
  • Size: 28.3 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.3.tar.gz
Algorithm Hash digest
SHA256 81773c863fc1b0865b1988567556a18fbc8a1e5dcc26ebc441155d7cad8be6ed
MD5 2df0f5a1e5cd7b88f54d4e4bd295dedd
BLAKE2b-256 09feca0b6b341b7680f5eb51f76f31191256dbcc735ee7aab2608166443003a1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cubeit-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 32.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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 499e6a2115d7b8d35c516766af93e3d3758195734eaf5eb15ce52ea38c36e224
MD5 cdc675d384ae98d12e53cb3eed1dcc6f
BLAKE2b-256 51b8fd35fba7fe2635bb4c2b35fa1fa28e10231d8af6ab06116de865cf9a41d3

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