Open wangpeng1111 opened 1 week ago
The default latex_str
is set to U
. There are several ways to redefine this.
gateclass.py
, change self.latex_str = r"U"
to self.latex_str = self.name
. This sets the default latex string to be the gate name.qc.gates[1].latex_str="cH"
. This is not recommended as the behaviour may change in the future, but this is a very quick hack fix for just this single gate.BTW, if you are willing to install the master branch, we have recently added a new plot mechanism and where you will get beautiful matplotlib plots by qc.draw("matplotlib")
hello, I have a question in https://qutip-qip.readthedocs.io/en/latest/qip-simulator.html.
from qutip_qip.circuit import QubitCircuit from qutip_qip.operations import ( Gate, controlled_gate, hadamard_transform) def controlled_hadamard():
Controlled Hadamard
qc = QubitCircuit(N=3, num_cbits=3) qc.user_gates = {"cH": controlled_hadamard} qc.add_gate("QASMU", targets=[0], arg_value=[1.91063, 0, 0]) qc.add_gate("cH", targets=[0,1]) qc.add_gate("TOFFOLI", targets=[2], controls=[0, 1]) qc.add_gate("X", targets=[0]) qc.add_gate("X", targets=[1]) qc.add_gate("CNOT", targets=[1], controls=0)
in the circuit , the custom gate "cH" can show in here, but when I try to custom another gate, there are just a "U" in the circuit, it cannot display defined names. when I copy this code in a new jupyter notebook, it also show "U" in the circuit, and not "cH" like https://qutip-qip.readthedocs.io/en/latest/qip-simulator.html.
I want to ask, how can I display a custom name in circuit with latex.