Ejemplo n.º 1
0
 def test_qasm_file(self):
     qasm_file = os.path.join(pq.__path__[0], 'tests', 'qasm_files',
                              "qasm_loader_test.qasm")
     loader = qasm_loader(qasm_file, 2)
     expected_result = [
         ".c1",
         "prepz q0",
         "prepz q1",
         "rx180 q0",
         '.c',  # this manual circuit remains in the code
         ".c3",
         "prepz q0",
         "prepz q1",
         'x q0',
         'measure q0',
         'measure q1',
         ".c4",
         "prepz q0",
         "prepz q1",
         'measure q0',
         'measure q1',
         'ry90 q0',
         'measure q0',
         'measure q1'
     ]
     self.assertEquals(loader.lines, expected_result)
Ejemplo n.º 2
0
 def __init__(self, qxc, filename):  # , num_circuits):
     super().__init__()
     self.name = 'QX_Hard_Sweep'
     self.filename = filename
     self.__qxc = qxc
     # self.num_circuits = num_circuits
     qasm = ql.qasm_loader(filename, qxc.get_nr_qubits())
     qasm.load_circuits()
     self.circuits = qasm.get_circuits()
Ejemplo n.º 3
0
 def __init__(self, qxc, filename): # , num_circuits):
     super().__init__()
     self.name = 'QX_Hard_Sweep'
     self.filename     = filename
     self.__qxc        = qxc
     # self.num_circuits = num_circuits
     qasm = ql.qasm_loader(filename)
     qasm.load_circuits()
     self.circuits = qasm.get_circuits()
Ejemplo n.º 4
0
 def __init__(self, qxc, filename, num_circuits, sweep_control='soft', sweep_points=None,**kw):
     super(QX_RB_Sweep, self).__init__()
     self.sweep_control = sweep_control
     self.name = 'QX_RB_Sweep'
     self.parameter_name = 'N_Clifford'
     self.unit = 'P'
     self.sweep_points = sweep_points
     self.__qxc = qxc
     self.__qxc.create_qubits(2)
     self.__cnt = 0
     self.filename = filename
     self.num_circuits = num_circuits
     qasm = ql.qasm_loader(filename)
     qasm.load_circuits()
     self.circuits = qasm.get_circuits()
     for c in self.circuits:
             self.__qxc.create_circuit(c[0],c[1])
Ejemplo n.º 5
0
 def __init__(self, qxc, filename, num_circuits, sweep_control='soft',
              sweep_points=None, **kw):
     super(QX_RB_Sweep, self).__init__()
     self.sweep_control = sweep_control
     self.name = 'QX_RB_Sweep'
     self.parameter_name = 'N_Clifford'
     self.unit = 'P'
     self.sweep_points = sweep_points
     self.__qxc = qxc
     self.__qxc.create_qubits(2)
     self.__cnt = 0
     self.filename = filename
     self.num_circuits = num_circuits
     qasm = ql.qasm_loader(filename)
     qasm.load_circuits()
     self.circuits = qasm.get_circuits()
     for c in self.circuits:
         self.__qxc.create_circuit(c[0], c[1])
Ejemplo n.º 6
0
    def test_replace(self):
        """
        test here if replacing lines works correctly
        """
        # empty file is used to initialize this test, all is overwritten
        # in the test
        qasm_file = os.path.join(pq.__path__[0], 'tests', 'qasm_files',
                                 "empty.qasm")
        loader = qasm_loader(qasm_file, 2)
        lines = [
            "qubits", "init_all", ".c", "x180", "invalid command", "init_all"
        ]
        results = []

        for l in lines:
            results.append(loader.replaceLine(l))

        self.assertFalse(results[0])
        self.assertEquals(results[1], [".c1", "prepz q0", "prepz q1"])
        self.assertFalse(results[2])
        self.assertFalse(results[3])
        self.assertFalse(results[4])
        self.assertEquals(results[5], [".c3", "prepz q0", "prepz q1"])