You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
The default latex_str is set to U. There are several ways to redefine this.
In 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.
Hack a bit and directly modify the stored gate object. Add 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
return controlled_gate(
hadamard_transform(1), controls=0, targets=1, control_value=1)
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.
The text was updated successfully, but these errors were encountered: