Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Supporting assignment of measurement value to variable

未关闭
#128 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@TheGupta2012 已经在做这个了。

开始于 2024年7月31日。

评估

这个 Issue 还没有评估数据。

描述

enhancement qasm3
Feature Description

Both of the following OpenQASM 3 strings generated using autoqasm fail program validation due to Unsupported expression type <class 'openqasm3.ast.BitstringLiteral'>. However, if generated directly from autoqasm, it seems they should be valid programs.

First:

import autoqasm as aq

@aq.main
def my_program():
    ins.h(0)
    ins.cnot(0, 1)
    return ins.measure([0, 1])

qasm_str = my_program.build().to_ir()

print(qasm_str)
OPENQASM 3.0;
output bit[2] return_value;
qubit[2] __qubits__;
h __qubits__[0];
cnot __qubits__[0], __qubits__[1];
bit[2] __bit_0__ = "00";
__bit_0__[0] = measure __qubits__[0];
__bit_0__[1] = measure __qubits__[1];
return_value = __bit_0__;

Second:

import autoqasm as aq

@aq.main
def my_program():
    ins.h(0)
    ins.cnot(0, 1)
    result = ins.measure([0, 1])
    return result

qasm_str = my_program.build().to_ir()

print(qasm_str)
OPENQASM 3.0;
output bit[2] result;
qubit[2] __qubits__;
h __qubits__[0];
cnot __qubits__[0], __qubits__[1];
bit[2] __bit_0__ = "00";
__bit_0__[0] = measure __qubits__[0];
__bit_0__[1] = measure __qubits__[1];
result = __bit_0__;

And both raise the following exception from validate() method:

from pyqasm import loads

program = loads(qasm_str)

program.validate()
...

ValidationError: Unsupported expression type <class 'openqasm3.ast.BitstringLiteral'>
主要语言
Python
星标
29
派生
33
平均合并
2 天 4 小时
30 天内合并 PR
15

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

qBraid/pyqasm 的其他 Issue

查看 qBraid/pyqasm 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。