pyzx
pyzx copied to clipboard
Q: preconditions for 'pyzx.extract_circuit`?
What are the minimum preconditions for pyzx.extract_circuit
to work? i presume equal number of inputs & outputs is the barest minimum, but I am not clear on the rest. I often get error like:
~/anaconda3/lib/python3.8/site-packages/pyzx/extract.py in filter_duplicate_cnots(cnots)
386 """Cancels adjacent CNOT gates in a list of CNOT gates."""
387 from .optimize import basic_optimization
--> 388 qubits = max([max(cnot.control,cnot.target) for cnot in cnots]) + 1
389 c = Circuit(qubits)
390 c.gates = cnots.copy() # type: ignore
ValueError: max() arg is an empty sequence
but I am tnot sure if that is a bug or if there is a problem with my graph
Hmm, that particular one looks like a bug. But to answer your question: it is really hard to give necessary preconditions for the extraction to work, as it depends on the graph having a gflow. But in any case: all spiders should be Z-spiders and maximally fused together.