示例#1
0
 def test_id_gate_with_explist(self):
     # FIXME: check # params.
     qasm = 'qreg q[10];' + \
            'u1(0.) q[0];' + \
            'u2(0., 0.) q[0];' + \
            'u3(0., 0., 0.) q[0];'
     # print(translate(qasm))
     mod = load_circuit(qasm)
示例#2
0
 def test_yacc_error(self):
     qasm = 'qreg q[10];\n' + \
            'h q[0]\n' + \
            'h q[1];\n' + \
            '_h q[2];\n' + \
            'h q[3];\n' + \
            'h q[4];\n'
     # print(translate(qasm))
     with self.assertRaises(SyntaxError):
         mod = load_circuit(qasm)
示例#3
0
 def test_barrier(self):
     qasm = 'qreg q[10];' + \
            'barrier q[0];'
     # print(translate(qasm))
     mod = load_circuit(qasm)
示例#4
0
 def test_reset_id(self):
     qasm = 'qreg q[10];' + \
            'reset q;'
     # print(translate(qasm))
     mod = load_circuit(qasm)
示例#5
0
 def test_load_empty_qasm(self):
     qasm = ''
     mod = load_circuit(qasm)
示例#6
0
 def test_measure_id(self):
     qasm = 'qreg q[10]; creg c[10];' + \
            'measure q -> c;'
     # print(translate(qasm))
     mod = load_circuit(qasm)
示例#7
0
 def test_id_gate_anylist_mixed(self):
     qasm = 'qreg q[10];' + \
            'h q[2], q;'
     # print(translate(qasm))
     mod = load_circuit(qasm)
示例#8
0
 def test_CX(self):
     qasm = 'qreg q[10];' + \
            'CX q[2], q[3];'
     mod = load_circuit(qasm)
示例#9
0
 def test_U_arguments(self):
     qasm = 'qreg q[10]; creg c[10];' + \
            'U(0., 0., 0.) q[0];' + \
            'U(0., 0., 0.) q;'
     # print(translate(qasm))
     mod = load_circuit(qasm)
示例#10
0
 def test_U(self):
     qasm = 'qreg q[10]; creg c[10];' + \
            'U(0., 0., 0.) q[2];' + \
            'U(0., 0., 0.) q;'
     mod = load_circuit(qasm)
示例#11
0
 def test_opaque(self):
     qasm = 'qreg q[10]; creg c[10];\n' + \
            'opaque opaque_gate() a, b, c;'
     with self.assertRaises(NotImplementedError):
         mod = load_circuit(qasm)
示例#12
0
 def test_gatedecl(self):
     qasm = 'qreg q[10]; creg c[10];' + \
            'gate custome_gate() a, b, c { }'
     with self.assertRaises(RuntimeError):
         mod = load_circuit(qasm)
示例#13
0
 def test_decl(self):
     qasm = 'qreg q[10]; creg c[10];'
     mod = load_circuit(qasm)
示例#14
0
 def test_exec_error(self):
     qasm = 'qreg q[10];' + \
            'barrier g;'
     # print(translate(qasm))
     with self.assertRaises(NameError):
         mod = load_circuit(qasm)