Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Warning instead of `ValidationError` for creg size = 0

Aperta
#179 5 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
29
Fork
33
Merge medio
2g 4h
PR unite (30g)
15

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di qBraid/pyqasm

Tutte le issue di qBraid/pyqasm

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.