Skip to content

Commit

Permalink
Wire indexing in ops tests (#67)
Browse files Browse the repository at this point in the history
* Wires

* pull PennyLane master
  • Loading branch information
antalszava committed Jan 28, 2021
1 parent 3c0baa5 commit 3ee122b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pyquil>=2.16
pennylane>=0.11
git+https://github.com/PennyLaneAI/pennylane.git
networkx
flaky
12 changes: 6 additions & 6 deletions tests/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ def test_cphase_decomposition(self, phi, q, tol):
gate_matrix = gate.matrix

if gate.num_wires == 1:
if gate.wires[0] == Wires(0):
if gate.wires[0] == 0:
gate_matrix = np.kron(gate_matrix, np.eye(2, dtype=complex))
elif gate.wires[0] == Wires(1):
elif gate.wires[0] == 1:
gate_matrix = np.kron(np.eye(2, dtype=complex), gate_matrix)

calculated_matrix = gate_matrix @ calculated_matrix
Expand All @@ -48,9 +48,9 @@ def test_pswap_decomposition(self, phi, tol):
gate_matrix = gate.matrix

if gate.num_wires == 1:
if gate.wires[0] == Wires(0):
if gate.wires[0] == 0:
gate_matrix = np.kron(gate_matrix, np.eye(2, dtype=complex))
elif gate.wires[0] == Wires(1):
elif gate.wires[0] == 1:
gate_matrix = np.kron(np.eye(2, dtype=complex), gate_matrix)

calculated_matrix = gate_matrix @ calculated_matrix
Expand All @@ -70,9 +70,9 @@ def test_iswap_decomposition(self, tol):
gate_matrix = gate.matrix

if gate.num_wires == 1:
if gate.wires[0] == Wires(0):
if gate.wires[0] == 0:
gate_matrix = np.kron(gate_matrix, np.eye(2, dtype=complex))
elif gate.wires[0] == Wires(1):
elif gate.wires[0] == 1:
gate_matrix = np.kron(np.eye(2, dtype=complex), gate_matrix)

calculated_matrix = gate_matrix @ calculated_matrix
Expand Down

0 comments on commit 3ee122b

Please sign in to comment.