libqasm Python Package
Project description
libQASM
libQASM is a library to parse cQASM programs, developed by QuTech. At the moment, libQASM only supports cQASM v3.0 programs (see cQASM-spec for the language specification).
It performs lexical, syntactic, and semantic analysis of an input program received via a file or a string. It produces one of the following results:
- A syntactic or semantic AST (Abstract Syntax Tree) object. Depending on if we are parsing or analysing.
- A list of parsing or analysing errors. In case the input program was malformed.
- A JSON representation of either the AST or the list of errors.
It can be used from:
- C++ projects (as a Conan package).
- Python projects (as a Python package).
- Emscripten projects (via a Typescript frontend).
Check out QX simulator and OpenSquirrel compiler for an example of use in a C++ and a Python project, respectively.
Getting started
Given a cQASM program example.cq
.
version 3.0
qubit[2] q
bit[2] b
H q[0]
CNOT q[0], q[1]
b = measure q
We can parse or analyze this circuit, using libQASM through the following programming language:
C++
#include "libqasm/v3x/cqasm-python.hpp"
int main() {
auto parse_result = V3xAnalyzer::parse_file("example.cq");
auto analyzer = V3xAnalyzer();
auto analysis_result = analyzer.analyze_file("example.cq");
}
Emscripten
The emscripten API only allows to input a cQASM program as a string.
import { default as wrapper } from 'cqasm_emscripten.mjs';
wrapper().then(function(result: any) {
let analyzer = new result["EmscriptenWrapper"]()
let program = `
version 3
qubit[2] q
bit[2] b
H q[0]
CNOT q[0], q[1]
b = measure q
`
let output = analyzer.parse_string_to_json(program)
analyzer.delete()
}).catch((error: any) => {
console.error("unhandledRejection", error, "\n");
});
Python
from libqasm import Analyzer
if __name__ == "__main__":
parse_result = Analyzer.parse_file('example.cq')
analyzer = Analyzer()
analysis_result = analyzer.analyze_file('example.cq')
Documentation
The libQASM documentation is hosted through GitHub Pages.
License
libQASM is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.
Authors
Quantum Inspire: support@quantum-inspire.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file libqasm-0.6.9-cp312-cp312-win_amd64.whl
.
File metadata
- Download URL: libqasm-0.6.9-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 800.3 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84c99d94a9d45c9487f6ff9be31ac849a4c8a704396ae67254db78b384942b7a |
|
MD5 | deaa1c0e1f18ffeabea3b421a8696596 |
|
BLAKE2b-256 | 8a7ffe382055551c9e84a2073e49ace38352d0717451c74369d803d2f690de32 |
File details
Details for the file libqasm-0.6.9-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: libqasm-0.6.9-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.9 MB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 822bbec51dba5cdf2fe865fa74b6a0e01c2c46fefc84c18a3e9159d6f1f1c33b |
|
MD5 | d06b72532a9f248f1180e8f3abfe6e4e |
|
BLAKE2b-256 | 8ac6138bb0dc31eb740b035581a60497dd6b1db02e9dde6b73cce4612546d5ce |
File details
Details for the file libqasm-0.6.9-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
.
File metadata
- Download URL: libqasm-0.6.9-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 1.8 MB
- Tags: CPython 3.12, manylinux: glibc 2.27+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68ff5857a877be0d44ea3d746c936ccc112b10312d686b74d890b8effb000799 |
|
MD5 | 976f4ca4413101e16d53a7cc5080b486 |
|
BLAKE2b-256 | ca361c864e013047c4865ff73d59ad3c958b0f0da1242aa3aea19276cf9c8030 |
File details
Details for the file libqasm-0.6.9-cp312-cp312-macosx_11_0_arm64.whl
.
File metadata
- Download URL: libqasm-0.6.9-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67ecc40f9c6f50dd5db0f1b949f677b3d8126b1bd3836fdf544c1e56d5fc11ba |
|
MD5 | fa2444139b2dcfb9eccc6938055b9a3c |
|
BLAKE2b-256 | 2033d810fde1503f746ea184862b7511108dce6e8f36b1bb7ae73ef212adddf2 |
File details
Details for the file libqasm-0.6.9-cp312-cp312-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: libqasm-0.6.9-cp312-cp312-macosx_10_9_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.12, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64b2fe7ce804b26e107ec1e5ddae4c37e311f056331b4fae723933fcd0901d54 |
|
MD5 | 5608b80e0812c382db275e8e6e226f86 |
|
BLAKE2b-256 | 2ca012df7d57cf7c9ae2445a2e70889948b6d15495f56f5147017294eb69569b |
File details
Details for the file libqasm-0.6.9-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: libqasm-0.6.9-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 799.7 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aaea4dad2c3742dc8e5d885363a2670249270f87c9c9030f67ae2b20355eeedb |
|
MD5 | b439c7467f5a60befd9b044288edd5cb |
|
BLAKE2b-256 | 20779d728357efacdfd74bcd4cec452c81e3bd5ca1c5c4c6e644c847b78f1fda |
File details
Details for the file libqasm-0.6.9-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: libqasm-0.6.9-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.9 MB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c5ec4d7eccbc06a49591c10101b2c6e5f76901854c9c998b0f216f0f11d2607 |
|
MD5 | 5cdeee1dd1504e35c057ece473288efd |
|
BLAKE2b-256 | c9bf99f302da25e7f7917405ac0bf033b95bf9d4a2374f23f4f8b5fb012e1446 |
File details
Details for the file libqasm-0.6.9-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
.
File metadata
- Download URL: libqasm-0.6.9-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 1.8 MB
- Tags: CPython 3.11, manylinux: glibc 2.27+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72cccc68793785e55cc16a288c7502781b324830ce868ce59fb09a35e75bfad0 |
|
MD5 | 96d0c4e9ea292558049e8707b0e4886d |
|
BLAKE2b-256 | db716682e00d49eae1fc98e96573f5c696bdbbb2adef653bf51c6c6a81028fa8 |
File details
Details for the file libqasm-0.6.9-cp311-cp311-macosx_11_0_arm64.whl
.
File metadata
- Download URL: libqasm-0.6.9-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06b1227deb4711bd8318abf8bea3f37c1c65bd0003ff4b4b2f286e0a1601a734 |
|
MD5 | a675a0b0717cadb890e84bda17da8f4f |
|
BLAKE2b-256 | 7fb8281fbbebbc29de8b78f9e4e5b7b42989c4c8c9cea4a8a968cdf0c5dc6bce |
File details
Details for the file libqasm-0.6.9-cp311-cp311-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: libqasm-0.6.9-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3cb4a7f75de569a23c43581b6d0e793c6218334b1b4d8d56b1ab8954083a5fd |
|
MD5 | 588d0b93f22a3e5f8eace9bffe9a944d |
|
BLAKE2b-256 | 043b1b8dbc923c679cd9e3cde594695057ded0705561aade4481ba5874f5db76 |
File details
Details for the file libqasm-0.6.9-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: libqasm-0.6.9-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 799.5 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f5f80f2ca02c16f590d0c02c6065ce400c39bdc7b3406d33934a63d54d5cf82 |
|
MD5 | 676982728b3ecaa4d5f9d110c75c4c3c |
|
BLAKE2b-256 | 22d114271914193a75b6418d8c1690e5214b9c238dfe5b9bce63879d9c471fb7 |
File details
Details for the file libqasm-0.6.9-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: libqasm-0.6.9-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.9 MB
- Tags: CPython 3.10, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62017c9630f20f3fa775dddae09dc1c70e7c44afeb26fde93c082c38393c5902 |
|
MD5 | fde2bb3ab543963809b757c6bc27b5e6 |
|
BLAKE2b-256 | caa037b5d51e438d5cefccade06c26e87763204895b756e1ece4f757a1f70025 |
File details
Details for the file libqasm-0.6.9-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
.
File metadata
- Download URL: libqasm-0.6.9-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 1.8 MB
- Tags: CPython 3.10, manylinux: glibc 2.27+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6db57611f5e048b04fede7f6dd102f5d94dfef6e77ac7301185d55673f122dab |
|
MD5 | a9d30b448c9f85f8f828869d1a6e55ee |
|
BLAKE2b-256 | 22e241fd4d12855ee429bd9687410e764d9077e29d33c8dc3f6b1e2f6acfcb30 |
File details
Details for the file libqasm-0.6.9-cp310-cp310-macosx_11_0_arm64.whl
.
File metadata
- Download URL: libqasm-0.6.9-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b66ec559db7ffaea0bd586139e4119fdbfaebd0c7c47ed899bb6744ba7964ef |
|
MD5 | 6b5ad03f95bd2800afb3e61d6f6b893f |
|
BLAKE2b-256 | 9b4b0d56d77d1f0655df23a375ef9718efbd3207170a74a925419fac7a134405 |
File details
Details for the file libqasm-0.6.9-cp310-cp310-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: libqasm-0.6.9-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31da6dbeaf14df4c3c796f1ae09d49bcdd5a52fb85ab8a7aa7475ad099691521 |
|
MD5 | 6c8d9f8f30232a97e743e5c9561eff99 |
|
BLAKE2b-256 | 47448b8f1d94abbed730dc302d3af0051b345d8ff3be2463b3953cdc0b52bf5a |
File details
Details for the file libqasm-0.6.9-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: libqasm-0.6.9-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 800.2 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 388c42972ca6700dd64612d6e5d7e1627ca37e1b9ed5e3eb69f85d68b0cb3508 |
|
MD5 | 329f813c817ee0f51e1e1a83df7b9398 |
|
BLAKE2b-256 | 0e87c4e1ece21815824f42a4c05cbcba9277e1303da4bc33440967a6fc5df949 |
File details
Details for the file libqasm-0.6.9-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: libqasm-0.6.9-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.9 MB
- Tags: CPython 3.9, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ebb0890a90cf9a31bc3d8be9d208aca7f906a7420d7eced54678df2ed72da53 |
|
MD5 | 93355b8c029a8beea141ab4dac89ee25 |
|
BLAKE2b-256 | 60ff36963acd61225de602b97b40496a9ee128a2f38479e7b7fca003e2ef95d8 |
File details
Details for the file libqasm-0.6.9-cp39-cp39-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
.
File metadata
- Download URL: libqasm-0.6.9-cp39-cp39-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 1.8 MB
- Tags: CPython 3.9, manylinux: glibc 2.27+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9e1e46d170ebe820e4e1215be56cbd2b83a5963638e2f69cc10269514b32e6d |
|
MD5 | 93b67db4b353ccd8bcedaa69f8059226 |
|
BLAKE2b-256 | 54860dbb42b7818cc633664e89441808e91ca4e081e268b42c7751ce8390d1b2 |
File details
Details for the file libqasm-0.6.9-cp39-cp39-macosx_11_0_arm64.whl
.
File metadata
- Download URL: libqasm-0.6.9-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79c2340455a85603ba8d1fd63f78e79bde1dd2902fed89b5bd40a8a643c15273 |
|
MD5 | c750197ea35478d755fef5eaa9bac914 |
|
BLAKE2b-256 | bde30707bf6786128123f7bad86e681411aff490f9d67f8301e772db6dee899f |
File details
Details for the file libqasm-0.6.9-cp39-cp39-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: libqasm-0.6.9-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49a04ccc5c271b496ecbc83c42beae95b3753f1180e19e242b613314e495874d |
|
MD5 | ba4b8827666ae29ce374fa5caf3a5e1b |
|
BLAKE2b-256 | 2b1edbc48568b84442c96d74f2c2638b22e0795b11e88631ebae21e8ddd0caab |