quantumlib / Stim

A fast stabilizer circuit library.
Apache License 2.0
356 stars 107 forks source link

CZ gate odd target length error message should print targets #817

Closed ghost closed 2 months ago

ghost commented 3 months ago
stim.Circuit('CZ')

ValueError: Two qubit gate CZ requires an even number of targets but was given ().

0 is an even number.

Strilanc commented 3 months ago

The given example passes without any error? Also it would be very weird for circuit parsing to mention a python tuple in its error output. Maybe you were calling circuit.append("CZ")? It wants you to say circuit.append("CZ", []), but is describing it badly. I can make the no-target version just work.

ghost commented 3 months ago

Actually, I think this is a case of me being confused by the error message: a=stim.Circuit('CZ') does work, and so does a.append('CZ')

stim.Circuit('CZ 0') actually gives the error message above. I guess this is an error message bug?

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[1], line 1
----> 1 stim.Circuit('''
      2     CZ 0
      3 ''')

ValueError: Two qubit gate CZ requires an even number of targets but was given ().

I had empty CZs in the circuit I was trying to construct, so assumed the message ment that's what it was complaining about.