Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Supporting assignment of measurement value to variable

Đang mở
#128 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@TheGupta2012 đang làm issue này rồi.

Từ ngày 31/7/2024.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

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'>
Ngôn ngữ chính
Python
Star
29
Fork
33
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
15

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của qBraid/pyqasm

Tất cả issue của qBraid/pyqasm

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.