Skip to main content

libqasm Python Package

Project description

libQASM

CI Conan Center cpp-linter PyPI OS License

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:

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

libqasm-1.2.1-cp313-cp313-win_amd64.whl (813.2 kB view details)

Uploaded CPython 3.13Windows x86-64

libqasm-1.2.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

libqasm-1.2.1-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (1.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

libqasm-1.2.1-cp313-cp313-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

libqasm-1.2.1-cp313-cp313-macosx_10_13_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

libqasm-1.2.1-cp312-cp312-win_amd64.whl (813.2 kB view details)

Uploaded CPython 3.12Windows x86-64

libqasm-1.2.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

libqasm-1.2.1-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (1.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

libqasm-1.2.1-cp312-cp312-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

libqasm-1.2.1-cp312-cp312-macosx_10_13_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

libqasm-1.2.1-cp311-cp311-win_amd64.whl (812.9 kB view details)

Uploaded CPython 3.11Windows x86-64

libqasm-1.2.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

libqasm-1.2.1-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (1.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

libqasm-1.2.1-cp311-cp311-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

libqasm-1.2.1-cp311-cp311-macosx_10_9_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

libqasm-1.2.1-cp310-cp310-win_amd64.whl (812.9 kB view details)

Uploaded CPython 3.10Windows x86-64

libqasm-1.2.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

libqasm-1.2.1-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (1.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

libqasm-1.2.1-cp310-cp310-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

libqasm-1.2.1-cp310-cp310-macosx_10_9_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

libqasm-1.2.1-cp39-cp39-win_amd64.whl (812.9 kB view details)

Uploaded CPython 3.9Windows x86-64

libqasm-1.2.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

libqasm-1.2.1-cp39-cp39-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (1.8 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

libqasm-1.2.1-cp39-cp39-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

libqasm-1.2.1-cp39-cp39-macosx_10_9_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

Details for the file libqasm-1.2.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: libqasm-1.2.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 813.2 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for libqasm-1.2.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 dfe354c3bffbb2404fd0e7c91c33845a5c06488771050e9f9ec76c2117752c4d
MD5 2e1d0623660a4201908fd3f782ff6250
BLAKE2b-256 d1ef6d32c19edd4d4f9f446cb0b086e4e6666fc0f2f4f4b8bec382fe0fa2cafc

See more details on using hashes here.

File details

Details for the file libqasm-1.2.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for libqasm-1.2.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c418cdb7cd84f78ef987c6ca55225f2f8ffdeec4283aeabca427346f40e1f741
MD5 76630efb701277011042d9e210a47c5a
BLAKE2b-256 5da1ea55f32186f785213d82cbc92aae3d54083046dad182f6b7631ec2c636a7

See more details on using hashes here.

File details

Details for the file libqasm-1.2.1-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for libqasm-1.2.1-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ca69e354a22d80c1ca7f6ae2a7dd095cb33fbc0b49de4afdf66463722321165d
MD5 1c4755b2ee15f338ec11be710ee709aa
BLAKE2b-256 325fa92b65d8cbd96fa8201da49c191b521324d62112867d93137e70deef5944

See more details on using hashes here.

File details

Details for the file libqasm-1.2.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for libqasm-1.2.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a51412e939aa9b5f329dffe050cf2483f81201489e51a6511dddf521c1d7c594
MD5 5a2a9cc6b9a92e39f8e59dab01cb271c
BLAKE2b-256 858b7cebede9916ee95734f3aa20f6b4e47aba8ac55a04e9170486a5218532f1

See more details on using hashes here.

File details

Details for the file libqasm-1.2.1-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for libqasm-1.2.1-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 832dd91d93af63f41f15bb15e20da895a92502aa9a7d5ddc89c4f1d34a521304
MD5 bf7c828dbfee9ed49ccf21feac4f2612
BLAKE2b-256 73293c5db5ec506df20475f4882df37ad8e23bf65eed2c6421a93c9d25cd884b

See more details on using hashes here.

File details

Details for the file libqasm-1.2.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: libqasm-1.2.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 813.2 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for libqasm-1.2.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8e14ebbfeaea9441d84b3950f472f5caea0a9ab3790bdd554141fb416899e566
MD5 ded398ab1bbb26301f4a1609b5e5c146
BLAKE2b-256 d319088a391f7a3cab3084a0ec4dce7325fa9a699c8e86068afd61b923aae5dc

See more details on using hashes here.

File details

Details for the file libqasm-1.2.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for libqasm-1.2.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f1918872005ecffe837d55758ab5c2039a25e823b527cec14b5e60b694b987cd
MD5 fbb42e9283f81ff5e7f0c1af399df7d8
BLAKE2b-256 3a20eb668b9cc354854925fc4a54a9d5372bb45987c522ca03a0d84fa9fe63a9

See more details on using hashes here.

File details

Details for the file libqasm-1.2.1-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for libqasm-1.2.1-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9ef94a3295bf28e4569d1178e6bcff8cb62c7b08e711c3360948946293e09dfe
MD5 a6642cbff96178224253bf910acb9245
BLAKE2b-256 16b607c7e74f788f3ead7797e30101666f91e8efa9dbb37f279d791f6f77dc4e

See more details on using hashes here.

File details

Details for the file libqasm-1.2.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for libqasm-1.2.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1f2e53598077a439349a01f365a7fe9f927a9153064ac2bd2efe9f9379dfb383
MD5 359ec4f3a9c3fe64178eb150fb199845
BLAKE2b-256 c21eb5f09546616483db76217d8e55d2f4cb23582f3f7c62ffe94d02fa5ae0ae

See more details on using hashes here.

File details

Details for the file libqasm-1.2.1-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for libqasm-1.2.1-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 4bad23d47b7fa04b6975c425b81e4c75080bfe6a8553ab6f6f06f1213f1e2850
MD5 2d7edb249bb5eca9d168e6366cea9453
BLAKE2b-256 1855626a3d712f879962c869123e0ecc03297fd4e23f750c30228ee5d467f911

See more details on using hashes here.

File details

Details for the file libqasm-1.2.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: libqasm-1.2.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 812.9 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for libqasm-1.2.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 469e65c26b9da8943b367e66d48a4a8273286fe8ba40c73b088558c9756b291c
MD5 5605a2c69b18a66ca1a480f877cfe7bd
BLAKE2b-256 9de8a70987abfb70aa6be0642453cf429eb625f0acc4e275fbeaf0c1e5fb4087

See more details on using hashes here.

File details

Details for the file libqasm-1.2.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for libqasm-1.2.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5c310e73f3b6f23acd2d308a46698c52bdee561d59dc0a8e455bf89ded24554a
MD5 23a1478425cbd290085027aa3fc22404
BLAKE2b-256 4939cada9ff3a56af495f884c52633929548e2459cd6626eaea81704f822d5ec

See more details on using hashes here.

File details

Details for the file libqasm-1.2.1-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for libqasm-1.2.1-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8158b75eccb8d2347f3c2ccdf0b14f722d0d478936a2c41275165c77ada0bdd0
MD5 4a727d14904e3f2b2deb9c6b84da2325
BLAKE2b-256 f91c66462640c09dfbc993fc722057e7fabe924d28d18ec61a80547ed6b70d3a

See more details on using hashes here.

File details

Details for the file libqasm-1.2.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for libqasm-1.2.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e8a9bf76b3e88a0773476bceac443c79ff4f46d30ca13a97b886a013d76daf49
MD5 5cf0f02fadd2f26767881242b45437de
BLAKE2b-256 83b30038765ce50e5ffef68f4334af690ae1883d57a381a81ce59e69bafcacfa

See more details on using hashes here.

File details

Details for the file libqasm-1.2.1-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for libqasm-1.2.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 04492faa8ef32b5aafb35548f37cd9247acc62cd7b53c4f6362028435b36e1a6
MD5 15b7e60959fdd306e81e7002cd61931f
BLAKE2b-256 25208a26189e4f4c4d5977cdf41a5ef24341fc879ac5f47e4dbcdaef72448424

See more details on using hashes here.

File details

Details for the file libqasm-1.2.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: libqasm-1.2.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 812.9 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for libqasm-1.2.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 600a7a54c3a60461d554105a9b62538d09aef75856cb0086545bbc93467ff837
MD5 155f10e6a55d1fd7f77796aa5bee66c9
BLAKE2b-256 63ff48333e38bd3ed6b17a0cee3e38e795e18c2b14088ce7634ebdcf1ae1e423

See more details on using hashes here.

File details

Details for the file libqasm-1.2.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for libqasm-1.2.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fe6e94cbe62697c7e44e809a9b5f396c37837f5348735366df099884f78a8a11
MD5 a4247e048e76dd9fd89024af4b1bab2c
BLAKE2b-256 1d29584b1148d5f5dd1cf4a9cc682abba2e3ef1808604ad871a58ee837ba5d08

See more details on using hashes here.

File details

Details for the file libqasm-1.2.1-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for libqasm-1.2.1-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e113b59ef51e6c52c99dd32b669b7945062a65550ce544ae5ecd8b7f71ee985a
MD5 6d60220053b0178b3015ba8b046cf1ca
BLAKE2b-256 57b5f9091c1c72c7fef49342599e846aa62d1f23d4777043a0b3473715072674

See more details on using hashes here.

File details

Details for the file libqasm-1.2.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for libqasm-1.2.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5be0873afccab6ac6a07c396989949fc56cbbfea12e33c8c7497a01f1b1c4413
MD5 5c95dc0573513f0c40041fe783fdca77
BLAKE2b-256 2aec25b6080c1e98785e5b953236f687e778d7725a28004cdcf9c6b64b904b05

See more details on using hashes here.

File details

Details for the file libqasm-1.2.1-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for libqasm-1.2.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e6146a6ee22c00542fc15323aaaca7105a2e45653193e73c97096ab86dec0560
MD5 4ea232d44cf5c6f29ba243886fbad802
BLAKE2b-256 6728bbb9fdb69bc129a4ce3bbd2abe1f994bcb3c990a23a74958ee9ff2b67280

See more details on using hashes here.

File details

Details for the file libqasm-1.2.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: libqasm-1.2.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 812.9 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for libqasm-1.2.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 9163a438f0a566e94048d62c824a6728b7328e8a5cc8eb48d93c5ddb289d9ee3
MD5 5e83ee2c1a15a11ced4c54e5aa7268c7
BLAKE2b-256 6f0e2df22d1fe01eff56b674e64d5577fc413841c9e043d8e6d0cf9b417305b7

See more details on using hashes here.

File details

Details for the file libqasm-1.2.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for libqasm-1.2.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1c89e8c223ab3eec42fc5d1975410333d644daa94a9f0adc6e24103d43abc86a
MD5 f2ada64c40ea098f5e4c7551e19e377b
BLAKE2b-256 29a1267eabad6868ac78b9b8d8f5c16de88c6c8a95c2a45d7ba034c6f061aef8

See more details on using hashes here.

File details

Details for the file libqasm-1.2.1-cp39-cp39-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for libqasm-1.2.1-cp39-cp39-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ac38d6592f755ad6ed21bcd3d7fe7b7cd941746a0595e985cbd778803368d79f
MD5 5012787884be67a36de3e587c252ed7b
BLAKE2b-256 c0fd10d1d11631056e0a9b204b9f833295837cc90f92ab7a2e94d6d2bdcda708

See more details on using hashes here.

File details

Details for the file libqasm-1.2.1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for libqasm-1.2.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4acd1b45de6385253fe7479d173b4d5ee808baa2cff651810ddd5b56928ca467
MD5 ea8377757450c0eab074e1c8625c1be8
BLAKE2b-256 c018bddc69b5def3ef5a5682580a4e09adc3324fdd60d57e712bc74bea4cd8e9

See more details on using hashes here.

File details

Details for the file libqasm-1.2.1-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for libqasm-1.2.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3ad0b673314569a90c0c96e81b18af0bc0ea41a5a3b9822eb508d2e76b37a6ed
MD5 112250fcc877da27e39548d991dfd382
BLAKE2b-256 959cc337cfcce696b5feedf9a55459e87cc13db829df65444dfe14f2a18168d0

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