Skip to content

Commit

Permalink
Add Open Graph tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wlcsm committed Jul 30, 2024
1 parent 8645da3 commit be0ea22
Show file tree
Hide file tree
Showing 21 changed files with 994 additions and 0 deletions.
3 changes: 3 additions & 0 deletions graphix/open_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import numpy as np
import pyzx as zx

from graphix.generator import generate_from_graph

Check failure on line 12 in graphix/open_graph.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (F401)

graphix/open_graph.py:12:31: F401 `graphix.generator.generate_from_graph` imported but unused
from graphix.sim.statevec import Statevec

Check failure on line 13 in graphix/open_graph.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (F401)

graphix/open_graph.py:13:34: F401 `graphix.sim.statevec.Statevec` imported but unused


@dataclass
class Measurement:
Expand Down
31 changes: 31 additions & 0 deletions tests/circuits/adder_n4.qasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
OPENQASM 2.0;
include "qelib1.inc";
qreg q[4];
creg c[4];
x q[0];
x q[1];
h q[3];
cx q[2],q[3];
t q[0];
t q[1];
t q[2];
tdg q[3];
cx q[0],q[1];
cx q[2],q[3];
cx q[3],q[0];
cx q[1],q[2];
cx q[0],q[1];
cx q[2],q[3];
tdg q[0];
tdg q[1];
tdg q[2];
t q[3];
cx q[0],q[1];
cx q[2],q[3];
s q[3];
cx q[3],q[0];
h q[3];
measure q[0] -> c[0];
measure q[1] -> c[1];
measure q[2] -> c[2];
measure q[3] -> c[3];
56 changes: 56 additions & 0 deletions tests/circuits/bell_n4.qasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Generated from Cirq v0.8.0

OPENQASM 2.0;
include "qelib1.inc";


// Qubits: [(0, 0), (0, 1), (1, 0), (1, 1)]
qreg q[4];
creg m_b[1];
creg m_y[1];
creg m_a[1];
creg m_x[1];


h q[0];
h q[1];
h q[3];
cx q[0],q[2];
rx(pi*-0.25) q[0];

// Gate: CNOT**0.5
ry(pi*-0.5) q[2];
u3(pi*0.5,0,pi*0.75) q[3];
u3(pi*0.5,0,pi*0.25) q[2];
rx(pi*0.5) q[3];
cx q[3],q[2];
rx(pi*0.25) q[3];
ry(pi*0.5) q[2];
cx q[2],q[3];
rx(pi*-0.5) q[2];
rz(pi*0.5) q[2];
cx q[3],q[2];
u3(pi*0.5,pi*0.5,pi*1.0) q[3];
u3(pi*0.5,pi*1.0,pi*1.0) q[2];
ry(pi*0.5) q[2];

// Gate: CNOT**0.5
ry(pi*-0.5) q[0];
u3(pi*0.5,0,pi*0.75) q[1];
u3(pi*0.5,0,pi*0.25) q[0];
rx(pi*0.5) q[1];
cx q[1],q[0];
rx(pi*0.25) q[1];
ry(pi*0.5) q[0];
cx q[0],q[1];
rx(pi*-0.5) q[0];
rz(pi*0.5) q[0];
cx q[1],q[0];
u3(pi*0.5,pi*0.5,pi*1.0) q[1];
u3(pi*0.5,pi*1.0,pi*1.0) q[0];
ry(pi*0.5) q[0];

measure q[2] -> m_b[0];
measure q[3] -> m_y[0];
measure q[0] -> m_a[0];
measure q[1] -> m_x[0];
14 changes: 14 additions & 0 deletions tests/circuits/cat_state_n4.qasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
OPENQASM 2.0;
include "qelib1.inc";
qreg bits[4];
creg c[4];

h bits[0];
cx bits[0],bits[1];
cx bits[1],bits[2];
cx bits[2],bits[3];

measure bits[0] -> c[0];
measure bits[1] -> c[1];
measure bits[2] -> c[2];
measure bits[3] -> c[3];
14 changes: 14 additions & 0 deletions tests/circuits/deutsch_n2.qasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Implementation of Deutsch algorithm with two qubits for f(x)=x
OPENQASM 2.0;
include "qelib1.inc";

qreg q[2];
creg c[2];

x q[1];
h q[0];
h q[1];
cx q[0],q[1];
h q[0];
measure q[0] -> c[0];
measure q[1] -> c[1];
Loading

0 comments on commit be0ea22

Please sign in to comment.