Skip to content

Commit

Permalink
Fix tests, add labels
Browse files Browse the repository at this point in the history
  • Loading branch information
ElePT committed Jun 24, 2024
1 parent f894c14 commit 826ae80
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 29 deletions.
10 changes: 5 additions & 5 deletions crates/circuit/src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ static STANDARD_GATE_NAME: [&str; STANDARD_GATE_SIZE] = [
"crz", // 31
"r", // 32
"ch", // 33
"cphase", // 34
"cp", // 34
"cs", // 35
"csdg", // 36
"csx", // 37
Expand Down Expand Up @@ -1059,7 +1059,7 @@ impl Operation for StandardGate {
2,
[
(Self::HGate, smallvec![], q1.clone()),
(Self::CU1Gate, smallvec![Param::Float(PI2)], q0_1),
(Self::CPhaseGate, smallvec![Param::Float(PI2)], q0_1),
(Self::HGate, smallvec![], q1),
],
FLOAT_ZERO,
Expand All @@ -1086,9 +1086,9 @@ impl Operation for StandardGate {
.expect("Unexpected Qiskit python bug"),
)
}),
Self::CUGate => None,
Self::CU1Gate => None,
Self::CU3Gate => None,
Self::CUGate => todo!(),
Self::CU1Gate => todo!(),
Self::CU3Gate => todo!(),
Self::C3XGate | Self::C3SXGate | Self::C4XGate => todo!(),
Self::DCXGate => todo!(),
Self::CCZGate => todo!(),
Expand Down
51 changes: 27 additions & 24 deletions qiskit/circuit/quantumcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4526,7 +4526,7 @@ def ch(
copy=False,
)
return self._append_standard_gate(
StandardGate.CHGate, [], qargs=[control_qubit, target_qubit]
StandardGate.CHGate, [], qargs=[control_qubit, target_qubit], label=label
)

def id(self, qubit: QubitSpecifier) -> InstructionSet: # pylint: disable=invalid-name
Expand Down Expand Up @@ -4607,7 +4607,7 @@ def cp(
copy=False,
)
return self._append_standard_gate(
StandardGate.CPhaseGate, [theta], qargs=[control_qubit, target_qubit]
StandardGate.CPhaseGate, [theta], qargs=[control_qubit, target_qubit], label=label
)

def mcp(
Expand Down Expand Up @@ -4975,9 +4975,7 @@ def ecr(self, qubit1: QubitSpecifier, qubit2: QubitSpecifier) -> InstructionSet:
Returns:
A handle to the instructions created.
"""
return self._append_standard_gate(
StandardGate.ECRGate, [], qargs=[qubit1, qubit2], cargs=None
)
return self._append_standard_gate(StandardGate.ECRGate, [], qargs=[qubit1, qubit2])

def s(self, qubit: QubitSpecifier) -> InstructionSet:
"""Apply :class:`~qiskit.circuit.library.SGate`.
Expand All @@ -4990,7 +4988,7 @@ def s(self, qubit: QubitSpecifier) -> InstructionSet:
Returns:
A handle to the instructions created.
"""
return self._append_standard_gate(StandardGate.SGate, [], [qubit], cargs=None)
return self._append_standard_gate(StandardGate.SGate, [], qargs=[qubit])

def sdg(self, qubit: QubitSpecifier) -> InstructionSet:
"""Apply :class:`~qiskit.circuit.library.SdgGate`.
Expand All @@ -5003,7 +5001,7 @@ def sdg(self, qubit: QubitSpecifier) -> InstructionSet:
Returns:
A handle to the instructions created.
"""
return self._append_standard_gate(StandardGate.SdgGate, [], [qubit], cargs=None)
return self._append_standard_gate(StandardGate.SdgGate, [], qargs=[qubit])

def cs(
self,
Expand Down Expand Up @@ -5038,7 +5036,7 @@ def cs(
)

return self._append_standard_gate(
StandardGate.CSGate, [], [control_qubit, target_qubit], cargs=None
StandardGate.CSGate, [], qargs=[control_qubit, target_qubit], label=label
)

def csdg(
Expand Down Expand Up @@ -5073,7 +5071,7 @@ def csdg(
copy=False,
)
return self._append_standard_gate(
StandardGate.CSdgGate, [], [control_qubit, target_qubit], cargs=None
StandardGate.CSdgGate, [], qargs=[control_qubit, target_qubit], label=label
)

def swap(self, qubit1: QubitSpecifier, qubit2: QubitSpecifier) -> InstructionSet:
Expand All @@ -5091,7 +5089,6 @@ def swap(self, qubit1: QubitSpecifier, qubit2: QubitSpecifier) -> InstructionSet
StandardGate.SwapGate,
[],
qargs=[qubit1, qubit2],
cargs=None,
)

def iswap(self, qubit1: QubitSpecifier, qubit2: QubitSpecifier) -> InstructionSet:
Expand All @@ -5105,7 +5102,7 @@ def iswap(self, qubit1: QubitSpecifier, qubit2: QubitSpecifier) -> InstructionSe
Returns:
A handle to the instructions created.
"""
return self._append_standard_gate(StandardGate.ISwapGate, [], [qubit1, qubit2], cargs=None)
return self._append_standard_gate(StandardGate.ISwapGate, [], qargs=[qubit1, qubit2])

def cswap(
self,
Expand All @@ -5132,7 +5129,6 @@ def cswap(
A handle to the instructions created.
"""
if ctrl_state is not None:

from .library.standard_gates.swap import CSwapGate

return self.append(
Expand All @@ -5142,7 +5138,10 @@ def cswap(
copy=False,
)
return self._append_standard_gate(
StandardGate.CSwapGate, [], [control_qubit, target_qubit1, target_qubit2], cargs=None
StandardGate.CSwapGate,
[],
qargs=[control_qubit, target_qubit1, target_qubit2],
label=label,
)

def sx(self, qubit: QubitSpecifier) -> InstructionSet:
Expand All @@ -5156,7 +5155,7 @@ def sx(self, qubit: QubitSpecifier) -> InstructionSet:
Returns:
A handle to the instructions created.
"""
return self._append_standard_gate(StandardGate.SXGate, None, qargs=[qubit])
return self._append_standard_gate(StandardGate.SXGate, [], qargs=[qubit])

def sxdg(self, qubit: QubitSpecifier) -> InstructionSet:
"""Apply :class:`~qiskit.circuit.library.SXdgGate`.
Expand All @@ -5169,7 +5168,7 @@ def sxdg(self, qubit: QubitSpecifier) -> InstructionSet:
Returns:
A handle to the instructions created.
"""
return self._append_standard_gate(StandardGate.SXdgGate, None, qargs=[qubit])
return self._append_standard_gate(StandardGate.SXdgGate, [], qargs=[qubit])

def csx(
self,
Expand All @@ -5193,13 +5192,17 @@ def csx(
Returns:
A handle to the instructions created.
"""
from .library.standard_gates.sx import CSXGate
if ctrl_state is not None:
from .library.standard_gates.sx import CSXGate

return self.append(
CSXGate(label=label, ctrl_state=ctrl_state),
[control_qubit, target_qubit],
[],
copy=False,
return self.append(
CSXGate(label=label, ctrl_state=ctrl_state),
[control_qubit, target_qubit],
[],
copy=False,
)
return self._append_standard_gate(
StandardGate.CSXGate, [], qargs=[control_qubit, target_qubit], label=label
)

def t(self, qubit: QubitSpecifier) -> InstructionSet:
Expand All @@ -5213,7 +5216,7 @@ def t(self, qubit: QubitSpecifier) -> InstructionSet:
Returns:
A handle to the instructions created.
"""
return self._append_standard_gate(StandardGate.TGate, [], [qubit], cargs=None)
return self._append_standard_gate(StandardGate.TGate, [], qargs=[qubit])

def tdg(self, qubit: QubitSpecifier) -> InstructionSet:
"""Apply :class:`~qiskit.circuit.library.TdgGate`.
Expand All @@ -5226,7 +5229,7 @@ def tdg(self, qubit: QubitSpecifier) -> InstructionSet:
Returns:
A handle to the instructions created.
"""
return self._append_standard_gate(StandardGate.TdgGate, [], [qubit], cargs=None)
return self._append_standard_gate(StandardGate.TdgGate, [], qargs=[qubit])

def u(
self,
Expand Down Expand Up @@ -5571,7 +5574,7 @@ def cz(
)

return self._append_standard_gate(
StandardGate.CZGate, [], qargs=[control_qubit, target_qubit], cargs=None, label=label
StandardGate.CZGate, [], qargs=[control_qubit, target_qubit], label=label
)

def ccz(
Expand Down

0 comments on commit 826ae80

Please sign in to comment.