Skip to content

Commit

Permalink
fix cswap definition bug (#685)
Browse files Browse the repository at this point in the history
* fix cswap definition bug

* add to changelog
  • Loading branch information
ajavadia authored and diego-plan9 committed Jul 26, 2018
1 parent 909728c commit 6c26436
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Removed
Fixed
-----
- Fixed ``probabilities_ket`` computation in C++ simulator. (#580)
- Fixed bug in the definition of ``cswap`` gate and its test (#685).
- Fixed the examples to be compatible with version 0.5+ (#672)


Expand Down
2 changes: 1 addition & 1 deletion qiskit/extensions/standard/cswap.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class FredkinGate(Gate):

def __init__(self, ctl, tgt1, tgt2, circ=None):
"""Create new Fredkin gate."""
super().__init__("ccx", [], [ctl, tgt1, tgt2], circ)
super().__init__("cswap", [], [ctl, tgt1, tgt2], circ)

def qasm(self):
"""Return OPENQASM string."""
Expand Down
15 changes: 1 addition & 14 deletions test/python/test_extensions_standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def test_crz_invalid(self):

def test_cswap(self):
self.circuit.cswap(self.q[0], self.q[1], self.q[2])
qasm_txt = 'cx q[2],q[1];\nccx q[0],q[1],q[2];\ncx q[2],q[1];'
qasm_txt = 'cswap q[0],q[1],q[2];'
self.assertResult(FredkinGate, qasm_txt, qasm_txt)

def test_cswap_invalid(self):
Expand Down Expand Up @@ -733,19 +733,6 @@ def test_rzz(self):
c.rzz(pi/2, self.q[1], self.q[2])
self.assertResult(RZZGate, 'rzz(pi/2) q[1],q[2];', 'rzz(-pi/2) q[1],q[2];')

def assertResult(self, t, qasm_txt, qasm_txt_):
"""
t: type
qasm_txt: qasm representation
qasm_txt_: qasm representation of inverse
"""
c = self.circuit
self.assertRaises(QISKitError, c.z, self.c[0])
self.assertRaises(QISKitError, c.z, self.c)
self.assertRaises(QISKitError, c.z, (self.q, 3))
self.assertRaises(QISKitError, c.z, (self.q, 'a'))
self.assertRaises(QISKitError, c.z, 0)

def test_z_reg(self):
qasm_txt = 'z q[0];\nz q[1];\nz q[2];'
instruction_set = self.circuit.z(self.q)
Expand Down

0 comments on commit 6c26436

Please sign in to comment.