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.3.0-cp313-cp313-win_amd64.whl (806.5 kB view details)

Uploaded CPython 3.13Windows x86-64

libqasm-1.3.0-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.3.0-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.3.0-cp313-cp313-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

libqasm-1.3.0-cp313-cp313-macosx_10_13_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

libqasm-1.3.0-cp312-cp312-win_amd64.whl (807.0 kB view details)

Uploaded CPython 3.12Windows x86-64

libqasm-1.3.0-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.3.0-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.3.0-cp312-cp312-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

libqasm-1.3.0-cp312-cp312-macosx_10_13_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

libqasm-1.3.0-cp311-cp311-win_amd64.whl (806.4 kB view details)

Uploaded CPython 3.11Windows x86-64

libqasm-1.3.0-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.3.0-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.3.0-cp311-cp311-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

libqasm-1.3.0-cp311-cp311-macosx_10_9_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

libqasm-1.3.0-cp310-cp310-win_amd64.whl (806.3 kB view details)

Uploaded CPython 3.10Windows x86-64

libqasm-1.3.0-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.3.0-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.3.0-cp310-cp310-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

libqasm-1.3.0-cp310-cp310-macosx_10_9_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

libqasm-1.3.0-cp39-cp39-win_amd64.whl (806.2 kB view details)

Uploaded CPython 3.9Windows x86-64

libqasm-1.3.0-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.3.0-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.3.0-cp39-cp39-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

libqasm-1.3.0-cp39-cp39-macosx_10_9_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: libqasm-1.3.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 806.5 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for libqasm-1.3.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7e5098d54f82bb28215b920e12e6d172c86f0847a6e2a8dbee1307c0f40bd607
MD5 c5f633fa0b51150bd881dc33725ede91
BLAKE2b-256 24f7ac9f64d5da0d1beb38895156c66aa9212343ac8bca4ec1dd3721e538b047

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for libqasm-1.3.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2fb0b050169331f422d0772f12ea79ae3c17734ae657e6a51d3c2b8c55dafefa
MD5 b9ef90717f8e364fb4a3776bc38e587e
BLAKE2b-256 ef375dc8e9a12e69d0f08ab2301541602e04a288bd26b13ca612086318849c48

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for libqasm-1.3.0-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f98dc80b28398fa2d26aa96e8c7e3264c683da85d099cbaf144b11995731be75
MD5 6729d462d5ccc5352f36842b2ba47e80
BLAKE2b-256 79bba4df48441f9c2878cb50c222b423ae7af7e566d74eb17a55dd7433388384

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for libqasm-1.3.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2af7874a8de5ffafcef2e487be623051207a6ba4bdb02f6d0962bcd3367ab7df
MD5 0a52d68795087675c2832e3839646aa9
BLAKE2b-256 2e802ebe36a5e155e81ac58dde0c453d7d98ccd64d03722b2f1a66ab2369939b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for libqasm-1.3.0-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 7d9ef2ce88fab529c3778160a9dca0e25a9b8cc0547ba53b4f776a3896ef4be2
MD5 3ad0c4c880000c18626f443faa8696dc
BLAKE2b-256 59776175ac7a3f2110d3bda1761e516918d6c6abf9af411867cf53c71ada8361

See more details on using hashes here.

File details

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

File metadata

  • Download URL: libqasm-1.3.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 807.0 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for libqasm-1.3.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d84fbb9a72e0613831c300c78e8461f1024af54c83c8e7a30a41c09db62962c9
MD5 f7a78142802b094be37fe1ba326caf19
BLAKE2b-256 4780418cc656acd2fd691bb0146886ade8b1639adf5f9cd8c9e8f1f31dba2b51

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for libqasm-1.3.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 53f223a76430a2c553eb597009b3e74092ffab517e504443cd82b7baec79d3d4
MD5 5b50a43fbe0818942daae6fc79e649e7
BLAKE2b-256 4533ac0432025860a76e3c0ce0d9b0843412c65ffe7738e1bfea3e65153900d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for libqasm-1.3.0-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 06303f882c6cde3eb6d06cf9b941a6d6a986162eb0c7abf3962ea578a36dc3c9
MD5 f5d92c609544636aa6940d6ca08cf9ee
BLAKE2b-256 c0341e3fea6cce99becc7a746367117ad6acc41e9eacfddae5a65a9875c61dfd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for libqasm-1.3.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8310d6eebf778047a3c40624be5feccbfe41f149ec5961dfa0787cc208992fa9
MD5 c2dfb2ce8720a6da1a01f0e1bf41598b
BLAKE2b-256 ff79ad66f23f86681f7e8c2ce34a75426de9b065c012eb502fd1f9c33ffed5f4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for libqasm-1.3.0-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 48cbea57f69097e7c2b0de1c7a705c20d73e5c5264dc4b752524383abb21b625
MD5 211dab328eebdbfd2c2dfce766336362
BLAKE2b-256 97fd1fcb8182c16a1dbf803a486765e48f5ab925eb195bd29bb2e90d40040866

See more details on using hashes here.

File details

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

File metadata

  • Download URL: libqasm-1.3.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 806.4 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for libqasm-1.3.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a7964c8fae178e522bffc7fed4665923840837d9ccf19bb81f0972f9e4d6cf12
MD5 1e3c6e1386b78718fccdde380958ba4c
BLAKE2b-256 581bca7eb4eeb04b2d4280e62d0ab6af8b2efe731d01cb6c916b8af1e74efae2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for libqasm-1.3.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0330475e7c72d4d76ac212180c783a939a93235f761c251df95529e61c479d29
MD5 5ae2ff3ec216eaa07611b071f4980053
BLAKE2b-256 9d007ef36af6f15ba804a315371b33b49e8d23ed4cc236cd5ca9e803e72c05ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for libqasm-1.3.0-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cbd2c6ba2216def6658416e8f05aa80668d33f8703a5c91e360018d5c63390cc
MD5 a31c182e5f61ec1c211117f251bfa210
BLAKE2b-256 cf5ae131649679a706be834b6b53657b642097216aecc682143f30c14c187ddd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for libqasm-1.3.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5e2883faa4545e6f6da07bea663a92d0da1860082f8e883da66b7d9c8644a118
MD5 7da484719e9e189f57880db66b4364fe
BLAKE2b-256 cf16ed30dbd1e535a75acc53b6379f73ee6990bb885834cc4c72291c5b6037a4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for libqasm-1.3.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1ab828b0c21733930d40dea9eeb64bf5c88afc9c5913dfcb9c98b73a9ebb8faa
MD5 554f6540c01489c28e15ef4be1fd666e
BLAKE2b-256 62cfdda7795e1f695fd19bcc90ea28fab32f9d26160074d2127d1bbc25b329b3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: libqasm-1.3.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 806.3 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for libqasm-1.3.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 dbee296d5507fff771b2294533fb90c45597e51c42297d3366b8fb5ae8abb0c4
MD5 4ecfd47c8009ac9db01a04c284f9f601
BLAKE2b-256 d5f8a1f3aa90c971ab868630f1815f6d9f14612fa53c5daf6444748a12a044da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for libqasm-1.3.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f4ba2510b5bbb5fbfbb2606085ccf0579497aeb3f23fa686be824461593f63b3
MD5 30473ca98f5e539feb74cc993b8f6b79
BLAKE2b-256 53772734032eddbea1685bbdfd9e1cc2faeeb964f9948c38a00fa81e9e989f5d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for libqasm-1.3.0-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 56ff14d68210843cccb5b98da5e35a63a0de368a4978a9b32c13e0f78afa8bfa
MD5 564821d2e96dc4ede5003fd9bc7f441a
BLAKE2b-256 b9474a92ca3fc52b68bf108a4603a429e8d3489ccd3d0ae1cef5fefeb31fda84

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for libqasm-1.3.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 87256faa4356044e554221463cd3f6ef93ef822c577a2836b0789aac1777d992
MD5 8c854f4a80d63611478c8f921f5f1c94
BLAKE2b-256 1878f37860fcc8297a52cd88f981935b1839f0b55f4cf3b05d39e7821d270774

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for libqasm-1.3.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3679f0ad1566d2596aa97c7937662a13fad8849cff6cc5c538996b779ef74c6c
MD5 ab0562fd65b3794d6573a480148ce3a2
BLAKE2b-256 f6018e5abbbd316a9e91e205d19b6d0a35c4adb2b1143370ad5d366770bfaad1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: libqasm-1.3.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 806.2 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for libqasm-1.3.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 cdd540bfca36bae6a9d55ef7d754d70310c5335dc1d9bbdcebdf956b452537ba
MD5 9123d32abecd56d54deed2bf99454017
BLAKE2b-256 425712bfc1542f9c94c678c7e0f1fd575074c6dd07d225865cbdd7e967583d30

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for libqasm-1.3.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7e970a5e7e404a78d33e7100aff212e0e1f56208c19555d1a054a61129d96abe
MD5 0b6de6809cfa8deac316ef6d527cfac6
BLAKE2b-256 7d1e08b0f1e895f4825cb29441998dafbc41cc8ba52127e8865726e71f728009

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for libqasm-1.3.0-cp39-cp39-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e7abc16ee4aed036779bbd582eb036044d8801c49b107ebe797979fcf95ea997
MD5 0cc8214d91142a9473f4b62d963813f2
BLAKE2b-256 10d0dd29e619efcac54c24deae9a2a7e756de544623c55cc810f7cb882d00307

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for libqasm-1.3.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a414ca2bab2a4d4d0481f0a632fcfd0ae80acb2921e0016eec0625072a6c93eb
MD5 49868730d589bbacbc8d84c6bce3db7f
BLAKE2b-256 5e1d75132a7370f3fb62a72190fcef443f82704847c6e297fc143c6d327c97cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for libqasm-1.3.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 395d808b090f7d1c4bc67023a341745859074e16db5a65d1c14c8cd58fcc511c
MD5 f0f49b365f426537e4316455f871ff6e
BLAKE2b-256 3fbb6f56afe99d9007bdc0c00042fa01931e607cbc6f6829a9612d3897498448

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