From 0f944aa53cd22d05a4bf70ef0f2762604dfa1b19 Mon Sep 17 00:00:00 2001 From: Chris Elenbaas Date: Mon, 15 Jun 2026 14:38:51 +0200 Subject: [PATCH 1/2] Adjust libQASM parser to parse measure aliases. --- opensquirrel/reader/libqasm_parser.py | 15 +++++++-- pyproject.toml | 2 +- tests/parser/libqasm/test_libqasm.py | 27 ++++++++++++++++ uv.lock | 44 +++++++++++++-------------- 4 files changed, 63 insertions(+), 25 deletions(-) diff --git a/opensquirrel/reader/libqasm_parser.py b/opensquirrel/reader/libqasm_parser.py index 27edc3ab..940454f7 100644 --- a/opensquirrel/reader/libqasm_parser.py +++ b/opensquirrel/reader/libqasm_parser.py @@ -37,6 +37,12 @@ class LibQasmParser: + _MEASURE_ALIASES: dict[str, list[Float]] = { + "measureX": [Float(1), Float(0), Float(0)], + "measureY": [Float(0), Float(1), Float(0)], + "measureZ": [Float(0), Float(0), Float(1)], + } + def __init__(self) -> None: self.ir = IR() @@ -181,8 +187,11 @@ def _get_expanded_measure_args(self, instruction: cqasm.semantic.NonGateInstruct else: msg = f"argument {ast_arg!r} is neither of qubit nor bit type" raise TypeError(msg) - if instruction.parameters: + + parameters = self._MEASURE_ALIASES.get(instruction.name) + if not parameters and instruction.parameters: parameters = [self._ast_literal_to_ir_literal(parameter) for parameter in instruction.parameters] + if parameters: number_of_operands = len(expanded_args[0]) expanded_args.append([parameters] * number_of_operands) return list(zip(*expanded_args, strict=False)) @@ -217,6 +226,8 @@ def _get_gate_generator(self, instruction: cqasm.semantic.GateInstruction) -> Ca def _get_non_gate_instruction_generator( self, instruction: cqasm.semantic.NonGateInstruction ) -> Callable[..., NonUnitary | ControlInstruction]: + if instruction.name in self._MEASURE_ALIASES: + return lambda *args: default_non_unitary_set["measure"](*args) if instruction.name in default_control_instruction_set: return lambda *args: default_control_instruction_set[instruction.name](*args) return lambda *args: default_non_unitary_set[instruction.name](*args) @@ -302,7 +313,7 @@ def circuit_from_string(self, s: str) -> Circuit: instruction_generator = self._get_non_gate_instruction_generator(statement) expanded_args = ( self._get_expanded_measure_args(statement) - if statement.name == "measure" + if statement.name == "measure" or statement.name in self._MEASURE_ALIASES else self._get_expanded_instruction_args(statement) ) elif LibQasmParser._is_asm_declaration(statement): diff --git a/pyproject.toml b/pyproject.toml index 9afc0b5a..7d512821 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ keywords = [ "compilation", ] dependencies = [ - "libqasm==1.4.0", + "libqasm==1.4.1", "networkx>=3.4.2", "numpy>=2.2.6", "scipy>=1.15.3", diff --git a/tests/parser/libqasm/test_libqasm.py b/tests/parser/libqasm/test_libqasm.py index b852e221..69c6fdaa 100644 --- a/tests/parser/libqasm/test_libqasm.py +++ b/tests/parser/libqasm/test_libqasm.py @@ -181,6 +181,33 @@ def test_parse_parameterized_measurement() -> None: ) +def test_parse_measurement_aliases() -> None: + circuit = LibQasmParser().circuit_from_string( + """ + version 3.0 + + qubit[3] q + bit[3] b + + b[0] = measureX q[0] + b[1] = measureY q[1] + b[2] = measureZ q[2] + """, + ) + assert ( + str(circuit) + == """version 3.0 + +qubit[3] q +bit[3] b + +b[0] = measure(1.0, 0.0, 0.0) q[0] +b[1] = measure(0.0, 1.0, 0.0) q[1] +b[2] = measure q[2] +""" + ) + + def test_sgmq() -> None: circuit = LibQasmParser().circuit_from_string( """ diff --git a/uv.lock b/uv.lock index 713bbe47..06683b65 100644 --- a/uv.lock +++ b/uv.lock @@ -2009,33 +2009,33 @@ wheels = [ [[package]] name = "libqasm" -version = "1.4.0" +version = "1.4.1" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "numpy", version = "2.2.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, { name = "numpy", version = "2.4.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" }, ] wheels = [ - { url = "https://files.pythonhosted.org/packages/b1/f7/ed42142b9b99774f3ca6303521a08733ca7455e02825822d969f2cf12160/libqasm-1.4.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:ea9fef74c62192a33de2f9cc5ddf0058e26d72971ff9478c4578c5d6971d7966", size = 1208780, upload-time = "2026-06-05T14:44:35.585Z" }, - { url = "https://files.pythonhosted.org/packages/55/b7/03d22d9784ff429e5530c5144773b94f95bd648449a94950a34188def827/libqasm-1.4.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:349bb6de44d753e41cbf95741878bd45ce627cf4c9986044f0f08edea968bff8", size = 1163891, upload-time = "2026-06-05T14:44:37.604Z" }, - { url = "https://files.pythonhosted.org/packages/29/a3/6b22637e65831f971abcdbd5b070f4b45d1b13d8bd3a9c6f6f29871689ee/libqasm-1.4.0-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:e758d46009151d1ae949c56172b067cde29bfcbd5a1ebf11f222651d441792ff", size = 1774355, upload-time = "2026-06-05T14:44:39.333Z" }, - { url = "https://files.pythonhosted.org/packages/24/a4/1fb4b8a43227285d709577213706f341a9007dc14182fbebbe7937baac2b/libqasm-1.4.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:77ac4d176eaadd5b144c8713521f6c578d6595c72cb48ba0b49be798c9dd684b", size = 1933525, upload-time = "2026-06-05T14:44:41.167Z" }, - { url = "https://files.pythonhosted.org/packages/e0/11/e614bf3d1dd429268aab9be42e7abf835b8f0465e7ade2a811ebf3d2dcb3/libqasm-1.4.0-cp310-cp310-win_amd64.whl", hash = "sha256:994aca1e985a1f33ff4bdccbffa11fc589fcf932b45c7e8890de3b5122f7beac", size = 809795, upload-time = "2026-06-05T14:44:43.705Z" }, - { url = "https://files.pythonhosted.org/packages/ed/e5/3f83be60bb0524cc6a6e93ebf126887d5911f0a5bb08049f53094597b75d/libqasm-1.4.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4c6a82ded6d6fa1a4c7dcf9658052e6a687aa276a090b7b94ecb0f642f679800", size = 1208779, upload-time = "2026-06-05T14:44:45.226Z" }, - { url = "https://files.pythonhosted.org/packages/5a/9e/0f3ffb3078844b463dc3b38ed9cc9df21582d9c63e583d286cbdd255ec70/libqasm-1.4.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:49a5b1b57e4d4f01a63efe45e2dbcc1f9e9bbb09b98ff994339848479afa9941", size = 1163890, upload-time = "2026-06-05T14:44:46.858Z" }, - { url = "https://files.pythonhosted.org/packages/47/21/c6cd328feaebfa6b3db3df9e47be5f454d5ad38678ba60b05b0004dc08c5/libqasm-1.4.0-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:36caf75d05da56574fae9ed3f4833c117c4f5fa5ed91cbc8b97c7d4156d60d96", size = 1774333, upload-time = "2026-06-05T14:44:48.665Z" }, - { url = "https://files.pythonhosted.org/packages/79/1c/a5f1029fabe7d96f5b19d648c0af638417133d12bfdeaa0f67076d1f7499/libqasm-1.4.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d7c150105a5b8af5af1b8aa92d0848fe33ab74a8e299ac67fc5609526c71f821", size = 1933529, upload-time = "2026-06-05T14:44:50.295Z" }, - { url = "https://files.pythonhosted.org/packages/a0/ee/9c1ec350d131153cd6397539f1debc21c70c61b22df29be5891c7b652232/libqasm-1.4.0-cp311-cp311-win_amd64.whl", hash = "sha256:ef209761553757ea07f45a6f7e451b51ec84b1a2011562602c8dbd8fbb507f43", size = 809910, upload-time = "2026-06-05T14:44:52.006Z" }, - { url = "https://files.pythonhosted.org/packages/62/f9/2babfcb39a824346998ca812c66dc2b7161a6ad6f3ab92f8739c2b36d2c1/libqasm-1.4.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:71e88bfdc4622cf81cb1fa89ef5e24bede2116e052c42dba385d6ec49cf8ab43", size = 1208285, upload-time = "2026-06-05T14:44:53.694Z" }, - { url = "https://files.pythonhosted.org/packages/d3/29/78c78fc5f9c30da423eca97bf5547df72dd38177467cd54fbaffa62ac76f/libqasm-1.4.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b6b8bc1ac4da98751a07f9b97270d4b31134234466ff15b68f6a69ccf38ae8cc", size = 1164874, upload-time = "2026-06-05T14:44:55.389Z" }, - { url = "https://files.pythonhosted.org/packages/e3/f0/8b23e8adf1a3f849f9361ed6ad1fda25182cf417037082c7eaca0e692d52/libqasm-1.4.0-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:4a9790048d4923e673da48b0952756539fc26ad6eccd96520819aca8577c05dc", size = 1774262, upload-time = "2026-06-05T14:44:57.053Z" }, - { url = "https://files.pythonhosted.org/packages/6c/d6/4837f671f8a529ffae0936eb5c644c16a1145a88584da7da34b87c9f597f/libqasm-1.4.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:44b7b1dbf3f68380dd1622db846f2519376187b7c1c566b5760e52a1fbc394c1", size = 1933829, upload-time = "2026-06-05T14:44:58.985Z" }, - { url = "https://files.pythonhosted.org/packages/2a/ef/2d6a9218a474aea98378d61cee87924341661b20d01194ceff392f21f521/libqasm-1.4.0-cp312-cp312-win_amd64.whl", hash = "sha256:1bb5bb87bb01a81de0bc8f716d2b03e44d83288c7f093e455ea9f725e0a3c51f", size = 810741, upload-time = "2026-06-05T14:45:00.673Z" }, - { url = "https://files.pythonhosted.org/packages/26/81/ea230d4fd19c18b5986bc9d9c61aaf36db50fcf204a96fd73dfea2fb8eed/libqasm-1.4.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:8d98ae67f3d13877ccca26b1349906cf906b45becfdd603225f612b29e215d59", size = 1208426, upload-time = "2026-06-05T14:45:02.278Z" }, - { url = "https://files.pythonhosted.org/packages/d2/c1/2f4da51f9cde413151328cc2f44674ecb01e0b1725b43c4958d18a0861ae/libqasm-1.4.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:3a57e9cd04fa131830b189ef226d44ffce895f7752fb22191c17e5c8dd436461", size = 1164545, upload-time = "2026-06-05T14:45:03.802Z" }, - { url = "https://files.pythonhosted.org/packages/70/f1/77d5ed0054e83942773e840d69539f9c012d736e8d66d6056ddd5edef88e/libqasm-1.4.0-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:e56ee1784f234678d4eddd56748045fade9be4704871cad0c067e8dc94f40c55", size = 1773824, upload-time = "2026-06-05T14:45:05.547Z" }, - { url = "https://files.pythonhosted.org/packages/c9/12/4fd3324fcdcd59a18c3d309347059ea9f83e85d7351f4a85d1d34f00152d/libqasm-1.4.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a0f4047cc7f3c373d380952c8de46481ed2cb24a7209f32981fb76274ea3956a", size = 1933102, upload-time = "2026-06-05T14:45:07.172Z" }, - { url = "https://files.pythonhosted.org/packages/df/ca/237c4fbf3d925d446dbb0e19d2cb0f8a615b823b1a8b7634df2c6406562e/libqasm-1.4.0-cp313-cp313-win_amd64.whl", hash = "sha256:f843fa46b226a17576ddd641cb8c1c65c0956dc50c8b51d1f34276c1df4ccc9a", size = 809949, upload-time = "2026-06-05T14:45:08.867Z" }, + { url = "https://files.pythonhosted.org/packages/20/9e/210d0a80d4466527f9528f0036adcc54ab52743f68fb6d0ad799dfb77217/libqasm-1.4.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d1b49b2fd0fd9c1deaf29bfa807ba228283227b2563ad324e50d49825b8402be", size = 1208679, upload-time = "2026-06-15T11:36:39.527Z" }, + { url = "https://files.pythonhosted.org/packages/dc/e1/3112d30b26992a33e08bb80983f5c0c2f9097f62d1400b22f5f640ee6c81/libqasm-1.4.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:09d98c4e398c5668ec5023487ec52505644508e1626b090f4e9f0bf580d0ab62", size = 1163770, upload-time = "2026-06-15T11:36:41.227Z" }, + { url = "https://files.pythonhosted.org/packages/9e/71/9c5b9c7eb6a389570445199f105585470306323c066826dba88cae785cbd/libqasm-1.4.1-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:794edfdf45567d58b11cc82b7687621703ae6a972a595427f46af98c29024553", size = 1774396, upload-time = "2026-06-15T11:36:43.341Z" }, + { url = "https://files.pythonhosted.org/packages/a0/0e/4b48025e00cdfde73c35f2002ea5ed0cf7a0ba85e645f422e353bce3391c/libqasm-1.4.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d546a49b0aa9799e941f34bfb835478e55dcf40e626ce8aa4191f90b6198799d", size = 1933511, upload-time = "2026-06-15T11:36:45.117Z" }, + { url = "https://files.pythonhosted.org/packages/aa/80/1a44e550d0194d0c8e9cfe8f3a903c6d102a4582aadd3f6978a79c79a088/libqasm-1.4.1-cp310-cp310-win_amd64.whl", hash = "sha256:15de3df1afa1b68e6a0ca0b6a5bb824796c18085f86c7c5b8fbdf650b1f11f9d", size = 798493, upload-time = "2026-06-15T11:36:46.5Z" }, + { url = "https://files.pythonhosted.org/packages/c3/f2/55f8161ba2745d0fb0a90ee63761adb669c2b9fe3c4c27485b6e63026dcc/libqasm-1.4.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:7cc92f4de7c056ffac4d0787095407ecf25b0bb08b1c19b38bbbe2dd47507cd4", size = 1208678, upload-time = "2026-06-15T11:36:48.239Z" }, + { url = "https://files.pythonhosted.org/packages/02/7d/7cc1bb7a6892921bfb00c0110115468984276069cd5f236272b547d8abbb/libqasm-1.4.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:da41eca44b765108ce817856e9e9e3c56cb9147ff5e4dc0783845164b38fbfa1", size = 1163764, upload-time = "2026-06-15T11:36:49.843Z" }, + { url = "https://files.pythonhosted.org/packages/9b/78/d364c3d9d40474d74677874963c2e4aa9949ca23a6fa4c32ecb680520340/libqasm-1.4.1-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:65765d22aa91b6c9a814981ce10bd53f365714b8e844175b59ac6a5a2dbb9cfa", size = 1774414, upload-time = "2026-06-15T11:36:51.838Z" }, + { url = "https://files.pythonhosted.org/packages/31/a8/59f0296b5aaa92763c9bde635f6e3c5f33c90e70f58752b8ca57efe0820a/libqasm-1.4.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:df260702453d1c72c7ec020a32277ffc29f9a5a5a32ce607fa390bd840c9619a", size = 1933509, upload-time = "2026-06-15T11:36:54.199Z" }, + { url = "https://files.pythonhosted.org/packages/b6/8a/3ede0c82b530ee9fc2c1159e5452c6bae0474e9535db504373c55d65250c/libqasm-1.4.1-cp311-cp311-win_amd64.whl", hash = "sha256:bced406f8a983234d1c5f02b35195125ea07f59352ddcdb4ea5b96eeabcf6e40", size = 798518, upload-time = "2026-06-15T11:36:56.38Z" }, + { url = "https://files.pythonhosted.org/packages/2a/db/af17c235408b2a55f0ef2a6e766c91276957da05c352daf161c42976f92a/libqasm-1.4.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:207d7e2c9509d5d0f5b7409dff4d1a455cbe4ef7e3654f743794bf366cabf834", size = 1208370, upload-time = "2026-06-15T11:36:58.51Z" }, + { url = "https://files.pythonhosted.org/packages/35/82/1cf6be1efaed9eaa705a3fc80230af878714747976cc9f84476e861b7d31/libqasm-1.4.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:671073b95e175138fb349045303c9576a11024ecc13ad4357ab28810cb5915fe", size = 1164710, upload-time = "2026-06-15T11:37:00.229Z" }, + { url = "https://files.pythonhosted.org/packages/90/7d/1fdbc0ab5ef9f0a82a6ae6b81c64066026df09e5656d22df62287dd4010d/libqasm-1.4.1-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5b0a36a2db04680cc1fd80f87f3ee83b741670caf2c6751defd6200501a1ab15", size = 1774298, upload-time = "2026-06-15T11:37:01.829Z" }, + { url = "https://files.pythonhosted.org/packages/4a/04/4a73079af8dc53087009371ea548537e1c13dcd3c61d989b2afbff287bdc/libqasm-1.4.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:f6544d80363e8676b704cdfad41b6a812b6263806d262acc8024fd815a8bcc59", size = 1933834, upload-time = "2026-06-15T11:37:03.502Z" }, + { url = "https://files.pythonhosted.org/packages/fd/f5/183cfd1bdfad0a1454e017473c9c67606bf2cba069ad6501f7b33ea07d1e/libqasm-1.4.1-cp312-cp312-win_amd64.whl", hash = "sha256:42860d8195b7a48021fadc6dc4ad331c50b0bace4794bf301dc123a5fa78ea5b", size = 799690, upload-time = "2026-06-15T11:37:05.052Z" }, + { url = "https://files.pythonhosted.org/packages/6e/3b/0ddedcffd54cbbd92e9f4a8efb708e1d5635acf71e9478c495aced527d9a/libqasm-1.4.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:4f48ec76263495d9e17356c7390b246b422b3853f9687108b517e72cd9895521", size = 1208344, upload-time = "2026-06-15T11:37:06.88Z" }, + { url = "https://files.pythonhosted.org/packages/24/70/de3d0313a47bf91424622aa355ea3660fe9576080082fb16a15e5e66a05b/libqasm-1.4.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:7437c8c12fdc58fd7f00a72c3b528ffa172e6206425d037acee727ea1b4cf4fc", size = 1164573, upload-time = "2026-06-15T11:37:08.395Z" }, + { url = "https://files.pythonhosted.org/packages/5b/da/16b8c500afc67b41d6a0d875e747d6bdc478a520b9b9feb8d21d8e9e3d47/libqasm-1.4.1-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f1e5de4f3faa3b10f8fb89dba3e753e3d05684896848aad01eb6886907589c15", size = 1773815, upload-time = "2026-06-15T11:37:10.01Z" }, + { url = "https://files.pythonhosted.org/packages/9d/87/7aff2de11e7e51adfcb6c95a73435c651460cf68fc1297c02de1ce42d7d2/libqasm-1.4.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:dabbc6d84b99ec5de34ebf735c3dd3d210bc9ea2d968660071076a2034738060", size = 1933184, upload-time = "2026-06-15T11:37:11.703Z" }, + { url = "https://files.pythonhosted.org/packages/e4/81/6a323ac1c1f8dee4435d166e65aa345b375a7eb338f3d5caf79f5af1e1c2/libqasm-1.4.1-cp313-cp313-win_amd64.whl", hash = "sha256:87735047e8bcfe06d2e2398d18a4134b0b7ac9519752e29ae04fdf3e028a8daf", size = 799833, upload-time = "2026-06-15T11:37:13.253Z" }, ] [[package]] @@ -3292,7 +3292,7 @@ qgym-mapper = [ [package.metadata] requires-dist = [ - { name = "libqasm", specifier = "==1.4.0" }, + { name = "libqasm", specifier = "==1.4.1" }, { name = "networkx", specifier = ">=3.4.2" }, { name = "numpy", specifier = ">=2.2.6" }, { name = "scipy", specifier = ">=1.15.3" }, From 1cdf98cbc1d23adefed7246d2f2cf39676f064a7 Mon Sep 17 00:00:00 2001 From: Chris Elenbaas Date: Mon, 15 Jun 2026 14:44:33 +0200 Subject: [PATCH 2/2] Fix linting error. Add entry to Changelog. --- CHANGELOG.md | 1 + opensquirrel/reader/libqasm_parser.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a3f4b6b..b9f2489c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ arbitrarily applied mapper pass. - `Can2CZDecomposer` to decompose arbitrary two-qubit gates. - The following 2-qubit gates: `CV`, `CY`, `DCNOT`, `ECR`, `ISWAP`, `InvSqrtSWAP`, `M`, `MS`, `SqrtISWAP`, and `SqrtSWAP` - Add `add_instruction` method to the `CircuitBuilder` +- libQASM parser accepts measure instruction aliases: `measureX`, `measureY`, and `measureZ` ## [ 0.9.0 ] - [ 2025-12-19 ] diff --git a/opensquirrel/reader/libqasm_parser.py b/opensquirrel/reader/libqasm_parser.py index 940454f7..2a1637bc 100644 --- a/opensquirrel/reader/libqasm_parser.py +++ b/opensquirrel/reader/libqasm_parser.py @@ -2,7 +2,7 @@ from collections import OrderedDict from collections.abc import Callable -from typing import TYPE_CHECKING, Any, cast, overload +from typing import TYPE_CHECKING, Any, ClassVar, cast, overload import cqasm.v3x as cqasm import cqasm.v3x.types as cqasm_types @@ -37,7 +37,7 @@ class LibQasmParser: - _MEASURE_ALIASES: dict[str, list[Float]] = { + _MEASURE_ALIASES: ClassVar[dict[str, list[Float]]] = { "measureX": [Float(1), Float(0), Float(0)], "measureY": [Float(0), Float(1), Float(0)], "measureZ": [Float(0), Float(0), Float(1)],