Quantikz float_precision_angles is ignored

Aperta
#8,580 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
57/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Start with CircuitToQuantikz.__init__ and the call to protocols.circuit_diagram_info(...) that builds gate labels; the issue says the stored precision is not passed there. Check how render_circuit exposes options, then add coverage for precision values 1, 2, and 5 using the reproduction in the issue. Done means generated labels match the expected precision-dependent output.

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

Descrizione

kind/bug-report triage/discuss

Describe the issue

In cirq.contrib.quantikz, the float_precision_angles option has no effect. CircuitToQuantikz.__init__ accepts and stores it (default 2), but nothing reads it. Gate labels are built from protocols.circuit_diagram_info(...) called without a precision argument, so the output is always 3 digits regardless of the value passed. render_circuit also doesn't expose the option. I have a proposed fix for this issue.

Explain how to reproduce the bug or problem

import re
import cirq
from cirq.contrib.quantikz import CircuitToQuantikz

q = cirq.LineQubit(0)
circuit = cirq.Circuit(cirq.rx(0.123456789).on(q))

for p in (1, 2, 5):
    latex = CircuitToQuantikz(circuit, float_precision_angles=p).generate_latex_document()
    print(p, re.search(r"R_\{X\}\(.*?\)", latex).group())

Output:

1 R_{X}(0.039\pi)
2 R_{X}(0.039\pi)
5 R_{X}(0.039\pi)

The expected output is:

1 R_{X}(0)
2 R_{X}(0.04\pi)
5 R_{X}(0.0393\pi)

float_precision_angles is accepted but never used, so the angle is always formatted with Cirq's default 3 digits.

Tell us the version of Cirq where this happens

1.8.0.dev0

Lingua principale
Python
Stelle
5.1k
Fork
1.3k
Merge medio
1g 12h
PR unite (30g)
48

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 quantumlib/Cirq

Tutte le issue di quantumlib/Cirq

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.