Missing casts: `angle()` narrowing, `angle(float)`, and `int[n](bit[n])`
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 30/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Tranquilla
- Stack tecnologico
- python
- Ambito
- compilers, quantum-computing
Direzione di ricerca
Cast handling lives in Qasm3ExprEvaluator in src/pyqasm/expressions.py, with type maps in src/pyqasm/maps/expressions.py, and tests belong in tests/qasm3/test_casting.py. Start by reproducing the three rejected casts from the issue: angle[10](a + b), angle[20](f) from a float, and int[8](b) from a bit[8]. Note that the bit -> int case depends on the separate bit[n] operators issue, so it may need to wait. Done means each allowed cast returns the spec's value, angle narrowing matches the worked bit patterns, and forbidden casts raise a ValidationError naming both types.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Limitation
The allowed casts table permits float -> angle
and bit -> int, and the
floating-point numbers section shows
an angle narrowed to a smaller width with angle(...).
pyqasm rejects all three.
Example QASM failure
Narrowing an angle — the spec's own example:
OPENQASM 3.0;
angle[20] a = pi / 2;
angle[20] b = pi;
angle[10] c;
c = angle(a + b); // cast to angle[10]
ValidationError: Invalid initialization value for variable 'c'
float -> angle, marked Yes in the cast table:
OPENQASM 3.0;
float[64] f = 1.0;
angle[20] a = angle(f);
// ValidationError: Invalid initialization value for variable 'a'
bit -> int, also marked Yes:
OPENQASM 3.0;
bit[8] b = "00000101";
int[8] i = int[8](b);
// ValidationError: Invalid initialization value for variable 'i'
Casts that already work: int[n](float), uint(float), bool(int), bit[n](int).
Change Requested
angle(x)andangle[n](x)wherexis afloator anangle, applying the spec's
fixed-point semantics: anangle[n]represents a value in[0, 2π)withnbits of
precision, so narrowing truncates the low-order bits.int[n](b)anduint[n](b)wherebis abit[n], interpreting the bit register as the
integer's binary representation.- A cast the spec's table forbids must raise a
ValidationErrornaming both types, rather
than the current generic"Invalid initialization value"message.
Not in scope
float(duration)— the cast table marks this No;pyqasm's current rejection is correct.float(angle)— the table also marks this No, though the spec's own comparison example uses
it.pyqasmcurrently accepts it. Worth raising upstream onopenqasm/openqasmto settle
the inconsistency before changing behaviour either way.
Implementation Details
- Cast handling is in
Qasm3ExprEvaluator(src/pyqasm/expressions.py) together with the type
maps insrc/pyqasm/maps/expressions.py. - Angle semantics are the substantive part. An
angle[n]is a fixed-point value: the stored
integer isround(value / (2π) * 2**n), and narrowing fromangle[m]toangle[n]with
n < mtruncates. Implementing that as an explicit representation makes the spec's worked
results —7 * (pi / 8)asangle[4]being"0111"— directly assertable in tests. bit -> intdepends on the width-carrying bit representation from thebit[n]operators
issue; sequence that one first.- Encoding the spec's cast table as an explicit
(from_type, to_type) -> allowedmap gives
correct rejection messages for free and documents the supported surface in one readable
place. - Tests:
tests/qasm3/test_casting.py— each newly supported cast with its expected value,
angle narrowing against the spec's worked bit patterns, and a forbidden cast asserting a
ValidationErrorthat names both types.
- Lingua principale
- Python
- Stelle
- 29
- Fork
- 33
- Merge medio
- 2g 4h
- PR unite (30g)
- 15
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di qBraid/pyqasm
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement error-handling program-validation
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Move the QASM 2 printer and its branch pre-processing out of qasm2.pyForse già presa @danielgaskins l’ha presa 8 giorni fa. Apertaenhancement qasm2
Difficoltà 4/5 3-5 giorni Idoneità per principianti 22/100
qBraid/pyqasm#447 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG] dumps() emits extern calls without a semicolon, producing unparsable QASMForse già presa @Jah-yee l’ha presa 16 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 25/100
qBraid/pyqasm#438 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Parse failures raise ValidationError with an empty message; the ANTLR diagnostic is lostForse già presa @tonycoder-hub l’ha presa 10 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 22/100
qBraid/pyqasm#436 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di qBraid/pyqasm
Issue simili
-
[Bug]: Revit selector reads process ids 2000-2099 as years (flaky AgentClientTests.AYearOrAProcessIdSelectsTheHost)Forse già presa @Wurschdhaud l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
pyrevitlabs/pyRevit#3817 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
521xueweihan/HelloGitHub#4074 ·
-
follow-up
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
Helm chart: allow setting ingressClassName on the IngressForse già presa @commarla l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
pgadmin-org/pgadmin4#10658 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100