Skip to content
Merged
Show file tree
Hide file tree
Changes from 80 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
facebce
rename the gates according to terra issue #3633
Cryoris Jan 7, 2020
90a3f77
fix typos, quotes
Cryoris Jan 7, 2020
88ffc11
replace gate names in qiskit and test dirs
Cryoris Jan 7, 2020
9321041
replace qc.iden by qc.i
Cryoris Jan 7, 2020
6ba88cb
fix lint, and some leftover renamings
Cryoris Jan 7, 2020
088fcb5
add matrix representation of CY
Cryoris Jan 7, 2020
b874a38
UCG -> UCGate and .ucg -> uc
Cryoris Jan 7, 2020
a6aeb19
UC(X,Y,Z) -> UCR(X,Y,Z)Gate and uc(x,y,z) -> ucr(x,y,z)
Cryoris Jan 7, 2020
9630d37
fix line length
Cryoris Jan 7, 2020
802500f
fix lint
Cryoris Jan 8, 2020
cb57b88
add deprecation warnings for old classes
Cryoris Jan 8, 2020
75a6528
fix missing theta arg
Cryoris Jan 8, 2020
5070665
Merge branch 'master' into consistent_gate_naming
Cryoris Jan 8, 2020
2b0642c
fix test, test type via subclass not "== type"
Cryoris Jan 8, 2020
f9ee1d5
add reno changelog for the gate names
Cryoris Jan 9, 2020
c126f05
resolve merge conflicts
Cryoris Jan 10, 2020
7d702c7
Merge branch 'master' into consistent_gate_naming
Cryoris Jan 10, 2020
45f09e1
rename UCRot -> UCPauliRotGate
Cryoris Jan 10, 2020
9cddb2e
rename ucrot file, fix line len
Cryoris Jan 10, 2020
f2b4246
rename Sdg -> Sinv, sdg -> sinv
Cryoris Jan 13, 2020
e831eca
fix metaclass instancecheck
Cryoris Jan 13, 2020
4011f96
fix parser test
Cryoris Jan 13, 2020
87d9feb
rename Tdg -> Tinv, tdg -> tinv
Cryoris Jan 13, 2020
a24d80b
fix text drawer test
Cryoris Jan 13, 2020
86e079f
update to non-deprecated qc methods
Cryoris Jan 13, 2020
38d4189
test.python.test_qasm_parser.TestParser.test_parser
1ucian0 Jan 14, 2020
9279213
support both *dg/*inv in qelib1.inc
Cryoris Jan 15, 2020
5d93bb0
Merge branch 'consistent_gate_naming' of github.com:Cryoris/qiskit-te…
Cryoris Jan 15, 2020
76a2346
*dg must remain standard extensions in AstInterpreter
Cryoris Jan 16, 2020
fba1f28
name: ucrot(X,Y,Z) -> ucr(x,y,z), fix (doc)strings along the way
Cryoris Jan 16, 2020
918c087
add test on all qelib1.inc gates
Cryoris Jan 16, 2020
0a33761
fix *inv -> *Inv naming
Cryoris Jan 20, 2020
e5ef275
fix missing renamings, use all_gates.qasm instead of a str
Cryoris Jan 20, 2020
89ed3d6
correct gate label for sinv/tinv
Cryoris Jan 20, 2020
26ff0d9
start renaming "id" -> "i"
Cryoris Jan 20, 2020
805377c
rename all id -> i
Cryoris Jan 21, 2020
e7b5899
reno: fix typos, update gate list
Cryoris Jan 21, 2020
bf1dac2
add i gate to qasm
Cryoris Jan 21, 2020
4f6ec66
deprecation warnings adhere to contribution guidelines
Cryoris Jan 21, 2020
4f8ac24
fix id json keyword
Cryoris Jan 21, 2020
c22b7cf
fix modified png file
Cryoris Jan 21, 2020
abfb330
remove obsolete if case
Cryoris Jan 21, 2020
06409e0
set deprecation version to 0.12.0
Cryoris Jan 21, 2020
b625908
revert changes on backend configs
Cryoris Jan 23, 2020
1642fe3
keep sdg,tdg,id as valid aliases
Cryoris Jan 23, 2020
8287999
revert names to id/sdg/tdg
Cryoris Jan 26, 2020
13757d0
Merge branch 'master' into consistent_gate_naming
ewinston Jan 28, 2020
6aa4e7b
update error message
ewinston Feb 3, 2020
1112a9f
Merge branch 'consistent_gate_naming' of https://github.com/Cryoris/q…
ewinston Feb 4, 2020
8de290a
avoid cyclic imports
ewinston Feb 4, 2020
a5f76d9
Merge pull request #1 from ewinston/Cryoris-consistent_gate_naming
Cryoris Feb 4, 2020
8405c05
rename the method diag_gate to diag, update reno
Cryoris Feb 12, 2020
8b8f73c
add comment why Initialize is not unitary
Cryoris Feb 12, 2020
836969f
Merge branch 'master' of github.com:Qiskit/qiskit-terra into consiste…
Cryoris Feb 13, 2020
2e0bd5e
change deprecation version to 0.14.0
Cryoris Feb 13, 2020
667d6d2
fix lints, rename diag -> diagonal
Cryoris Feb 13, 2020
a6ec619
fix deprecation on import
Cryoris Feb 13, 2020
3f28106
Merge branch 'master' of github.com:Qiskit/qiskit-terra into consiste…
Cryoris Feb 13, 2020
4ef1e12
fix Cnot/CX naming
Cryoris Feb 13, 2020
92aceea
fix deprecation version
Cryoris Feb 13, 2020
e629949
Merge branch 'master' of github.com:Qiskit/qiskit-terra into consiste…
Cryoris Feb 13, 2020
efc9fd3
fix return of multiplexer pauli rotations
Cryoris Feb 13, 2020
21c4fb6
name swap uppercase throughout
Cryoris Feb 13, 2020
5007035
rename iso -> isometry (keep alias)
Cryoris Feb 13, 2020
48eaf99
Update deprecation warning
Cryoris Feb 14, 2020
26415e5
Update deprecation warning of ucx
Cryoris Feb 14, 2020
028d89c
Update deprecation warning of ucz
Cryoris Feb 14, 2020
98659d5
Merge branch 'master' into consistent_gate_naming
Cryoris Feb 14, 2020
6d3f19d
Update deprecation warning of ucy
Cryoris Feb 14, 2020
de3588b
fix redefine outer scope
Cryoris Feb 14, 2020
4fb3ca8
attempt fixing jupyter cells
Cryoris Feb 14, 2020
cd13878
move matrix repr from Fredkin to CSwap
Cryoris Feb 14, 2020
f1be570
add reno
Cryoris Feb 14, 2020
b05a9d1
Revert "move matrix repr from Fredkin to CSwap"
Cryoris Feb 14, 2020
3e0fb78
Revert "add reno"
Cryoris Feb 14, 2020
e09731c
unrevert revert
Cryoris Feb 14, 2020
95229ab
Merge branch 'master' into consistent_gate_naming
Cryoris Feb 14, 2020
b6b94ac
Merge branch 'master' into Cryoris-consistent_gate_naming
ewinston Feb 19, 2020
1f0f597
Merge pull request #2 from ewinston/Cryoris-consistent_gate_naming
Cryoris Feb 19, 2020
341b801
fix leftover Cnot
Cryoris Feb 19, 2020
8e82d5c
keep old quantum initializer classes but deprecate
Cryoris Feb 19, 2020
780f5e9
fix lint & test
Cryoris Feb 19, 2020
e5d9d15
add test for the deprecated classes
Cryoris Feb 19, 2020
cbf47c7
Merge branch 'master' into consistent_gate_naming
ewinston Feb 21, 2020
c6cadf7
Merge branch 'master' into consistent_gate_naming
ajavadia Feb 21, 2020
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: 0 additions & 2 deletions qiskit/assembler/disassemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ def _experiments_to_circuits(qobj):
conditional = {}
for i in x.instructions:
name = i.name
if i.name == 'id':
name = 'iden'
qubits = []
params = getattr(i, 'params', [])
try:
Expand Down
4 changes: 2 additions & 2 deletions qiskit/circuit/add_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def add_control(operation: Union[Gate, ControlledGate],
# the condition matching 'name' above is to catch a test case,
# 'TestControlledGate.test_rotation_gates', where the rz gate
# gets converted to a circuit before becoming a generic Gate object.
cgate = standard.CrzGate(*operation.params)
cgate = standard.CRZGate(*operation.params)
return cgate.control(num_ctrl_qubits - 1)
if isinstance(operation, UnitaryGate):
# attempt decomposition
Expand Down Expand Up @@ -119,7 +119,7 @@ def control(operation: Union[Gate, ControlledGate],
for rule in bgate.definition:
if rule[0].name == 'u3':
theta, phi, lamb = rule[0].params
if phi == -pi/2 and lamb == pi/2:
if phi == -pi / 2 and lamb == pi / 2:
qc.mcrx(theta, q_control, q_target[rule[1][0].index],
use_basis_gates=True)
elif phi == 0 and lamb == 0:
Expand Down
24 changes: 12 additions & 12 deletions qiskit/circuit/random/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

from qiskit.circuit import QuantumRegister, ClassicalRegister, QuantumCircuit
from qiskit.circuit import Reset
from qiskit.extensions import (IdGate, U1Gate, U2Gate, U3Gate, XGate,
from qiskit.extensions import (IGate, U1Gate, U2Gate, U3Gate, XGate,
YGate, ZGate, HGate, SGate, SdgGate, TGate,
TdgGate, RXGate, RYGate, RZGate, CnotGate,
CyGate, CzGate, CHGate, CrzGate, Cu1Gate,
Cu3Gate, SwapGate, RZZGate,
ToffoliGate, FredkinGate)
TdgGate, RXGate, RYGate, RZGate, CXGate,
CYGate, CZGate, CHGate, CRZGate, CU1Gate,
CU3Gate, SwapGate, RZZGate,
CCXGate, CSwapGate)
from qiskit.circuit.exceptions import CircuitError


Expand All @@ -49,14 +49,14 @@ def random_circuit(n_qubits, depth, max_operands=3, measure=False,
if max_operands < 1 or max_operands > 3:
raise CircuitError("max_operands must be between 1 and 3")

one_q_ops = [IdGate, U1Gate, U2Gate, U3Gate, XGate, YGate, ZGate,
one_q_ops = [IGate, U1Gate, U2Gate, U3Gate, XGate, YGate, ZGate,
HGate, SGate, SdgGate, TGate, TdgGate, RXGate, RYGate, RZGate]
one_param = [U1Gate, RXGate, RYGate, RZGate, RZZGate, Cu1Gate, CrzGate]
one_param = [U1Gate, RXGate, RYGate, RZGate, RZZGate, CU1Gate, CRZGate]
two_param = [U2Gate]
three_param = [U3Gate, Cu3Gate]
two_q_ops = [CnotGate, CyGate, CzGate, CHGate, CrzGate,
Cu1Gate, Cu3Gate, SwapGate, RZZGate]
three_q_ops = [ToffoliGate, FredkinGate]
three_param = [U3Gate, CU3Gate]
two_q_ops = [CXGate, CYGate, CZGate, CHGate, CRZGate,
CU1Gate, CU3Gate, SwapGate, RZZGate]
three_q_ops = [CCXGate, CSwapGate]

qr = QuantumRegister(n_qubits, 'q')
qc = QuantumCircuit(n_qubits)
Expand Down Expand Up @@ -96,7 +96,7 @@ def random_circuit(n_qubits, depth, max_operands=3, measure=False,
num_angles = 3
else:
num_angles = 0
angles = [rng.uniform(0, 2*np.pi) for x in range(num_angles)]
angles = [rng.uniform(0, 2 * np.pi) for x in range(num_angles)]
register_operands = [qr[i] for i in operands]
op = operation(*angles)

Expand Down
52 changes: 26 additions & 26 deletions qiskit/converters/ast_to_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
from qiskit.circuit.measure import Measure
from qiskit.circuit.reset import Reset
from qiskit.extensions.standard.barrier import Barrier
from qiskit.extensions.standard.x import ToffoliGate
from qiskit.extensions.standard.swap import FredkinGate
from qiskit.extensions.standard.x import CnotGate
from qiskit.extensions.standard.y import CyGate
from qiskit.extensions.standard.z import CzGate
from qiskit.extensions.standard.x import CCXGate
from qiskit.extensions.standard.swap import CSwapGate
from qiskit.extensions.standard.x import CXGate
from qiskit.extensions.standard.y import CYGate
from qiskit.extensions.standard.z import CZGate
from qiskit.extensions.standard.swap import SwapGate
from qiskit.extensions.standard.h import HGate
from qiskit.extensions.standard.iden import IdGate
from qiskit.extensions.standard.i import IGate
from qiskit.extensions.standard.s import SGate
from qiskit.extensions.standard.s import SdgGate
from qiskit.extensions.standard.t import TGate
Expand All @@ -46,14 +46,14 @@
from qiskit.extensions.standard.rx import RXGate
from qiskit.extensions.standard.ry import RYGate
from qiskit.extensions.standard.rz import RZGate
from qiskit.extensions.standard.u1 import Cu1Gate
from qiskit.extensions.standard.h import CHGate
from qiskit.extensions.standard.rx import CrxGate
from qiskit.extensions.standard.ry import CryGate
from qiskit.extensions.standard.rz import CrzGate
from qiskit.extensions.standard.u3 import Cu3Gate
from qiskit.extensions.standard.rxx import RXXGate
from qiskit.extensions.standard.rzz import RZZGate
from qiskit.extensions.standard.u1 import CU1Gate
from qiskit.extensions.standard.u3 import CU3Gate
from qiskit.extensions.standard.h import CHGate
from qiskit.extensions.standard.rx import CRXGate
from qiskit.extensions.standard.ry import CRYGate
from qiskit.extensions.standard.rz import CRZGate


def ast_to_dag(ast):
Expand Down Expand Up @@ -113,19 +113,19 @@ class AstInterpreter:
"ry": RYGate,
"rz": RZGate,
"rzz": RZZGate,
"id": IdGate,
"id": IGate,
"h": HGate,
"cx": CnotGate,
"cy": CyGate,
"cz": CzGate,
"cx": CXGate,
"cy": CYGate,
"cz": CZGate,
"ch": CHGate,
"crx": CrxGate,
"cry": CryGate,
"crz": CrzGate,
"cu1": Cu1Gate,
"cu3": Cu3Gate,
"ccx": ToffoliGate,
"cswap": FredkinGate}
"crx": CRXGate,
"cry": CRYGate,
"crz": CRZGate,
"cu1": CU1Gate,
"cu3": CU3Gate,
"ccx": CCXGate,
"cswap": CSwapGate}

def __init__(self, dag):
"""Initialize interpreter's data."""
Expand Down Expand Up @@ -239,11 +239,11 @@ def _process_cnot(self, node):
maxidx = max([len(id0), len(id1)])
for idx in range(maxidx):
if len(id0) > 1 and len(id1) > 1:
self.dag.apply_operation_back(CnotGate(), [id0[idx], id1[idx]], [], self.condition)
self.dag.apply_operation_back(CXGate(), [id0[idx], id1[idx]], [], self.condition)
elif len(id0) > 1:
self.dag.apply_operation_back(CnotGate(), [id0[idx], id1[0]], [], self.condition)
self.dag.apply_operation_back(CXGate(), [id0[idx], id1[0]], [], self.condition)
else:
self.dag.apply_operation_back(CnotGate(), [id0[0], id1[idx]], [], self.condition)
self.dag.apply_operation_back(CXGate(), [id0[0], id1[idx]], [], self.condition)

def _process_measure(self, node):
"""Process a measurement node."""
Expand Down
2 changes: 1 addition & 1 deletion qiskit/converters/dag_to_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def dag_to_circuit(dag):
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from qiskit.dagcircuit import DAGCircuit
from qiskit.converters import circuit_to_dag
from qiskit.extensions.standard import CHGate, U2Gate, CnotGate
from qiskit.extensions.standard import CHGate, U2Gate, CXGate
from qiskit.converters import dag_to_circuit
%matplotlib inline

Expand Down
22 changes: 11 additions & 11 deletions qiskit/extensions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@
:toctree: ../stubs/

Barrier
ToffoliGate
CCXGate
CHGate
CrxGate
CryGate
CrzGate
FredkinGate
Cu1Gate
Cu3Gate
CnotGate
CyGate
CzGate
CRXGate
CRYGate
CRZGate
CSwapGate
CU1Gate
CU3Gate
CXGate
CYGate
CZGate
HGate
IdGate
IGate
MSGate
RXGate
RXXGate
Expand Down
10 changes: 5 additions & 5 deletions qiskit/extensions/quantum_initializer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"""Initialize qubit registers to desired arbitrary state."""

from .squ import SingleQubitUnitary
from .ucz import UCZ
from .ucy import UCY
from .ucx import UCX
from .diag import DiagGate
from .ucg import UCG
from .ucrz import UCRZGate
from .ucry import UCRYGate
from .ucrx import UCRXGate
from .diagonal import DiagonalGate
from .uc import UCGate
from .isometry import Isometry
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
Decomposes a diagonal matrix into elementary gates using the method described in Theorem 7 in
"Synthesis of Quantum Logic Circuits" by Shende et al. (https://arxiv.org/pdf/quant-ph/0406176.pdf).
"""
import warnings
import cmath
import math

Expand All @@ -34,7 +35,7 @@
_EPS = 1e-10 # global variable used to chop very small numbers to zero


class DiagGate(Gate):
class DiagonalGate(Gate):
"""
diag = list of the 2^k diagonal entries (for a diagonal gate on k qubits). Must contain at
least two entries.
Expand All @@ -59,7 +60,7 @@ def __init__(self, diag):
if not np.abs(z) - 1 < _EPS:
raise QiskitError("A diagonal entry has not absolute value one.")
# Create new gate.
super().__init__("diag", int(num_action_qubits), diag)
super().__init__("diagonal", int(num_action_qubits), diag)

def _define(self):
diag_circuit = self._dec_diag()
Expand Down Expand Up @@ -87,7 +88,7 @@ def _dec_diag(self):
num_act_qubits = int(np.log2(n))
contr_qubits = q[self.num_qubits - num_act_qubits + 1:self.num_qubits]
target_qubit = q[self.num_qubits - num_act_qubits]
circuit.ucz(angles_rz, contr_qubits, target_qubit)
circuit.ucrz(angles_rz, contr_qubits, target_qubit)
n //= 2
return circuit

Expand All @@ -100,7 +101,7 @@ def _extract_rz(phi1, phi2):
return phase, z_angle


def diag_gate(self, diag, qubit):
def diagonal(self, diag, qubit):
"""Attach a diagonal gate to a circuit.

The decomposition is based on Theorem 7 given in "Synthesis of Quantum Logic Circuits" by
Expand Down Expand Up @@ -137,7 +138,17 @@ def diag_gate(self, diag, qubit):
if not len(qubit) == num_action_qubits:
raise QiskitError("The number of diagonal entries does not correspond to"
" the number of qubits.")
return self.append(DiagGate(diag), qubit)
return self.append(DiagonalGate(diag), qubit)


def diag_gate(self, diag, qubit):
"""Deprecated version of QuantumCircuit.diagonal."""
warnings.warn('The QuantumCircuit.diag_gate() method is deprecated as of 0.14.0, and '
'will be removed no earlier than 3 months after that release date. '
'You should use the QuantumCircuit.diagonal() method instead.',
DeprecationWarning, stacklevel=2)
return diagonal(self, diag, qubit)


QuantumCircuit.diag_gate = diag_gate
QuantumCircuit.diagonal = diagonal
QuantumCircuit.diag_gate = diag_gate # deprecated
8 changes: 5 additions & 3 deletions qiskit/extensions/quantum_initializer/initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from qiskit.circuit import QuantumCircuit
from qiskit.circuit import QuantumRegister
from qiskit.circuit import Instruction
from qiskit.extensions.standard.x import CnotGate
from qiskit.extensions.standard.x import CXGate
from qiskit.extensions.standard.ry import RYGate
from qiskit.extensions.standard.rz import RZGate
from qiskit.circuit.reset import Reset
Expand All @@ -37,6 +37,8 @@ class Initialize(Instruction):
Class that implements the (complex amplitude) initialization of some
flexible collection of qubit registers (assuming the qubits are in the
zero state).
Note that Initialize is an Instruction and not a Gate since it contains a reset instruction,
which is not unitary.
"""

def __init__(self, params):
Expand Down Expand Up @@ -221,7 +223,7 @@ def _multiplex(self, target_gate, list_of_angles):
circuit.append(multiplex_1.to_instruction(), q[0:-1])

# attach CNOT as follows, thereby flipping the LSB qubit
circuit.append(CnotGate(), [msb, lsb])
circuit.append(CXGate(), [msb, lsb])

# implement extra efficiency from the paper of cancelling adjacent
# CNOTs (by leaving out last CNOT and reversing (NOT inverting) the
Expand All @@ -233,7 +235,7 @@ def _multiplex(self, target_gate, list_of_angles):
circuit.append(multiplex_2.to_instruction(), q[0:-1])

# attach a final CNOT
circuit.append(CnotGate(), [msb, lsb])
circuit.append(CXGate(), [msb, lsb])

return circuit

Expand Down
Loading