Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed default labels for sdg, tdg, sx, and sxdg to None #4885

Merged
merged 7 commits into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion qiskit/circuit/library/standard_gates/s.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class SdgGate(Gate):
Equivalent to a :math:`\pi/2` radian rotation about the Z axis.
"""

def __init__(self, label='S_dg'):
def __init__(self, label=None):
"""Create new Sdg gate."""
super().__init__('sdg', 1, [], label=label)

Expand Down
4 changes: 2 additions & 2 deletions qiskit/circuit/library/standard_gates/sx.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class SXGate(Gate):

"""

def __init__(self, label='√X'):
def __init__(self, label=None):
"""Create new SX gate."""
super().__init__('sx', 1, [], label=label)

Expand Down Expand Up @@ -130,7 +130,7 @@ class SXdgGate(Gate):

"""

def __init__(self, label='√X_dg'):
def __init__(self, label=None):
"""Create new SXdg gate."""
super().__init__('sxdg', 1, [], label=label)

Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/standard_gates/t.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class TdgGate(Gate):
Equivalent to a :math:`\pi/2` radian rotation about the Z axis.
"""

def __init__(self, label='T_dg'):
def __init__(self, label=None):
"""Create new Tdg gate."""
super().__init__('tdg', 1, [], label=label)

Expand Down
4 changes: 2 additions & 2 deletions qiskit/visualization/qcstyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ def __init__(self):
'h': 'H',
's': 'S',
'sdg': '$\\mathrm{S}^\\dagger$',
'sx': '$\\sqrt{X}$',
'sxdg': '$\\sqrt{X}^\\dagger$',
'sx': '$\\sqrt{\\mathrm{X}}$',
'sxdg': '$\\sqrt{\\mathrm{X}}^\\dagger$',
't': 'T',
'tdg': '$\\mathrm{T}^\\dagger$',
'iswap': 'Iswap',
Expand Down
6 changes: 4 additions & 2 deletions qiskit/visualization/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from qiskit.circuit import Reset as ResetInstruction
from qiskit.circuit import Measure as MeasureInstruction
from qiskit.circuit import Barrier as BarrierInstruction
from qiskit.circuit.library.standard_gates import IGate, RZZGate, SwapGate
from qiskit.circuit.library.standard_gates import IGate, RZZGate, SwapGate, SXGate, SXdgGate
from qiskit.extensions import UnitaryGate, HamiltonianGate, Snapshot
from qiskit.extensions.quantum_initializer.initializer import Initialize
from qiskit.circuit.tools.pi_check import pi_check
Expand Down Expand Up @@ -776,7 +776,9 @@ def special_label(instruction):
labels = {IGate: 'I',
Initialize: 'initialize',
UnitaryGate: 'unitary',
HamiltonianGate: 'Hamiltonian'}
HamiltonianGate: 'Hamiltonian',
SXGate: '√X',
SXdgGate: '√XDG'}
instruction_type = type(instruction)
if instruction_type in {Gate, Instruction}:
return instruction.name
Expand Down
26 changes: 13 additions & 13 deletions test/python/visualization/references/circuit_text_ref.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
┌───┐┌───┐┌───┐ ░ ┌───┐┌───┐┌─────┐┌───┐┌─────┐┌────┐┌──────┐┌───┐ ┌────────┐┌────────┐┌────────┐┌────────┐┌───────────┐┌──────────────┐ ┌─┐
q_0: |0>┤ X ├┤ Y ├┤ Z ├─░─┤ H ├┤ S ├┤ S_dg ├┤ T ├┤ T_dg ├┤ √X ├┤ √X_dg ├┤ I ├─|0>─┤ RX(pi) ├┤ RY(pi) ├┤ RZ(pi) ├┤ U1(pi) ├┤ U2(pi,pi) ├┤ U3(pi,pi,pi) ├─X───■────■───■───■───■──────────■────────────■─────────■─────────■───────■───■─┤M├──────
└─░─┘└───┘└───┘ ░ └───┘└───┘└─────┘└───┘└─────┘└────┘└──────┘└───┘ └────────┘└────────┘└────────┘└────────┘└───────────┘└──────────────┘ │ ┌─┴─┐┌─┴─┐ │ ┌─┴─┐ │pi ┌──────┴───────┐┌───┴────┐┌───┴────┐┌───┴────┐ │ │ └╥┘┌─┐
q_1: |0>──░─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────X─┤ X ├┤ Y ├─■─┤ H ├─■───┤ U3(pi,pi,pi) ├┤ RZ(pi) ├┤ RY(pi) ├┤ RX(pi) ├──■───X──╫─┤M├───
└───┘└───┘ └───┘ └──────────────┘└────────┘└────────┘└────────┘┌─┴─┐ │ ║ └╥┘┌─┐
q_2: |0>──░────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ X ├─X──╫──╫─┤M├
└───┘ ║ ║ └╥┘
c_0: 0 ════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╩══╬══╬═
║ ║
c_1: 0 ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╩══╬═
c_2: 0 ══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╩═
┌───┐┌───┐┌───┐ ░ ┌───┐┌───┐┌─────┐┌───┐┌─────┐┌────┐┌──────┐┌───┐ ┌────────┐┌────────┐┌────────┐┌────────┐┌───────────┐┌──────────────┐ ┌─┐
q_0: |0>┤ X ├┤ Y ├┤ Z ├─░─┤ H ├┤ S ├┤ SDG ├┤ T ├┤ TDG ├┤ √X ├┤ √XDG ├┤ I ├─|0>─┤ RX(pi) ├┤ RY(pi) ├┤ RZ(pi) ├┤ U1(pi) ├┤ U2(pi,pi) ├┤ U3(pi,pi,pi) ├─X───■────■───■───■───■──────────■────────────■─────────■─────────■───────■───■─┤M├──────
└─░─┘└───┘└───┘ ░ └───┘└───┘└─────┘└───┘└─────┘└────┘└──────┘└───┘ └────────┘└────────┘└────────┘└────────┘└───────────┘└──────────────┘ │ ┌─┴─┐┌─┴─┐ │ ┌─┴─┐ │pi ┌──────┴───────┐┌───┴────┐┌───┴────┐┌───┴────┐ │ │ └╥┘┌─┐
q_1: |0>──░──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────X─┤ X ├┤ Y ├─■─┤ H ├─■───┤ U3(pi,pi,pi) ├┤ RZ(pi) ├┤ RY(pi) ├┤ RX(pi) ├──■───X──╫─┤M├───
░ └───┘└───┘ └───┘ └──────────────┘└────────┘└────────┘└────────┘┌─┴─┐ │ ║ └╥┘┌─┐
q_2: |0>──░─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ X ├─X──╫──╫─┤M├
░ └───┘ ║ ║ └╥┘
c_0: 0 ═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╩══╬══╬═
║ ║
c_1: 0 ════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╩══╬═
c_2: 0 ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╩═