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

Warning instead of `ValidationError` for creg size = 0

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

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

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python

Hướng nghiên cứu

The error comes from the check that rejects a non-positive creg size, reached through pyqasm.loads on the snippet in the issue. Find that check and the existing tests for creg size, then load the example with creg c[0]; to reproduce it. Done means that snippet loads with a warning suggesting the declaration be omitted, creg c[-1]; still raises ValidationError, and a size-0 creg used by a measurement still raises.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Currently, a program that includes a creg declaration with size 0 raises a ValidationError. The creg of size 0 is a convention used by pyqpanda3, which we are currently trying to integrate into the qBraid-SDK transpiler (https://github.com/qBraid/qBraid/pull/963). However, the ValidationError demonstrated below is causing errors in testing, see comment.

import pyqpanda3

program = pyqpanda3.core.QProg()
program << pyqpanda3.core.RX(0, 3.1415926) << pyqpanda3.core.CNOT(0, 2)

qasm = pyqpanda3.intermediate_compiler.convert_qprog_to_qasm(program)

print(qasm)
OPENQASM 2.0;
include "qelib1.inc";
qreg q[3];
creg c[0];
rx(3.14159260) q[0];
cx q[0],q[2];
import pyqasm

module = pyqasm.loads(qasm)
ValidationError: Failed to parse OpenQASM string: L4:C6: creg size must be positive

I think we should instead just emit a warning if creg size = 0, but still raise a ValidationError if creg size < 0. If creg size is set to 0, and no further creg operations exist in the program, I think the program should still be considered "valid", but we should emit a warning and recommend that instead of declaring a creg of size 0, they should just omit the creg declaration.

Obviously, if creg size is set to 0 and the program also contains a measurement operation, for example, that should still warrant a ValidationError.

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.