Example #1
0
def q3Test():

    dic = DictionarySearcher(3)

    matrix = np.eye(2**3, dtype=complex)
    """
    matrix[0,0] = 0
    matrix[1,0] = -1
    matrix[0,1] = 1j
    matrix[1,1] = 0

    matrix[2,2] = (1/math.sqrt(2))
    matrix[3,2] = (1/math.sqrt(2))
    matrix[2,3] = (1/math.sqrt(2))
    matrix[3,3] = (-1/math.sqrt(2))
    """

    for i in range(4, 8):
        for j in range(4, 8):
            matrix[i, j] = 0.5

    for i in range(4, 8):
        matrix[i, i] -= 1

    Debug.debug("\n" + str(matrix) + "\n\n", DebugLevel.Debug)
    id = AQP.generateSpecial(matrix=matrix, name="semiAA2", dic=dic)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)
Example #2
0
def grover4AATest():

    dic = DictionarySearcher(4)
    matrix = QuantumMath.getAmplitudAmplifier(4)
    id = AQP.generateSpecial(matrix=matrix, name="grover4AA", dic=dic)

    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)
Example #3
0
    def _error_state_manager(self):
        """"""
        dbg.debug(print, "Error State", debug=self._gs['debug'])

        # Store the last state
        self._store_last_state()

        # Go to stop state
        self._temp_test_state = enum.TempTestStatesEnum.TT_STOP
        pass
Example #4
0
    def _stop_state_manager(self):
        """"""
        dbg.debug(print, "Stop State", debug=self._gs['debug'])
        # Store the last state
        self._store_last_state()

        self._kill_scan_engine_app()

        # Stop read temperature thread
        self._read_temperature_thread.stop()
        self._csv_log_thread.stop()
        self._scan_engine_app_thread.stop()

        pass
Example #5
0
    def _run_scan_engine_app_state_manager(self):
        """"""
        print("-Run Scan Engine App")
        dbg.debug(print, "Run Scan Engine App ", debug=self._gs['debug'])

        # Run Scan Engine App
        ret = self._SX5.run_scan_engine_app()

        if ret == True:
            # Go to pull images state
            self._temp_test_state = enum.TempTestStatesEnum.TT_PULL_IMAGES
        else:
            # Go to error state
            self._temp_test_state = enum.TempTestStatesEnum.TT_ERROR
            return
Example #6
0
    def _init_sx5(self):
        """ """

        dbg.debug(print,
                  self._config_dict['SX5']['adb_pull_base_dir'],
                  debug=self._gs['debug'])

        # Init an SX5 instance
        self._SX5 = SX5_Manager(
            scan_engine=self._config_dict['SX5']['scan_engine'],
            num_frame=self._config_dict['SX5']['num_of_frame'],
            num_loop=self._config_dict['SX5']['num_of_loop'],
            num_save_files=self._config_dict['SX5']['num_of_save_files'],
            frame_storage_dir=self._config_dict['SX5']['frame_storage_dir'],
            pull_dir=self._config_dict['SX5']['adb_pull_base_dir'],
        )
        pass
Example #7
0
    def _init_state_manager(self):
        """"""
        dbg.debug(print, "Init State", debug=self._gs['debug'])

        # Parse config file
        self._parse_config_file()
        # Init SX5
        self._init_sx5()

        # Init Thermal Chamber
        self._init_thermal_chamber()

        # Init Image Manager
        self._init_image_manager()

        # Go to Run scan engine app state
        self._temp_test_state = enum.TempTestStatesEnum.TT_RUN_SCAN_ENGINE_APP
        return
Example #8
0
    def _run_scan_engine_app_state_manager(self):
        """"""
        dbg.debug(print, "-Run Scan Engine App", debug=self._gs['debug'])

        # Start Timer and run Scan Engine App Thread
        self._timer_dict['Global'].start()

        # Start threads
        self._scan_engine_app_thread.start()
        self._read_temperature_thread.start()
        self._csv_log_thread.start()

        # Store the last state
        self._store_last_state()

        # Go to Read Temperature state
        self._temp_test_state = enum.TempTestTS_StatesEnum.TT_READ_TEMP

        return
Example #9
0
    def _pull_images_state_manager(self):
        """"""
        dbg.debug(print, "Pull Images", debug=self._gs['debug'])
        print("-Pull images")

        # TODO: aggiungere la gestione degli errori

        # Pull image from device and clear the directory
        ret = self._SX5.pull_images()
        self._SX5.clear_frame_storage_dir()

        # Convert the pulled images
        self._image_manager.convert_images(show=False, save=True)

        if ret == True:
            # Go to stop state
            self._temp_test_state = enum.TempTestStatesEnum.TT_STOP
        else:
            # Go to error state
            self._temp_test_state = enum.TempTestStatesEnum.TT_ERROR

        return
Example #10
0
    def _init_sx5(self):
        """ """
        dbg.debug(print,
                  self._config_dict['SX5']['output_dir_name'],
                  debug=self._gs['debug'])
        dbg.debug(print,
                  int(self._config_dict['SX5']['num_of_frame']) *
                  int(self._config_dict['SX5']['num_of_loop']),
                  debug=self._gs['debug'])

        # Init an SX5 instance
        self._SX5 = SX5_Manager(
            scan_engine=self._config_dict['SX5']['scan_engine'],
            num_frame=self._config_dict['SX5']['num_of_frame'],
            num_loop=self._config_dict['SX5']['num_of_loop'],
            num_save_files=int(self._config_dict['SX5']['num_of_frame']) *
            int(self._config_dict['SX5']['num_of_loop']),
            callback_delay_ms=self._config_dict['SX5']['callback_delay_ms'],
            frame_storage_dir=self._config_dict['SX5']['frame_storage_dir'],
            pull_dir="",
        )
        # Disable scan service
        self._SX5.disable_scan_service()
        pass
Example #11
0
def memoryTest():

    # inicializa un diccionario para 4 qubits
    dic = DictionarySearcher(nQubits=4)

    # genera una puerta de giro condicionado multiple y las subpuertas necesarias
    gateId = AQP.generateMultipleTurn(sources=[0, 1, 2],
                                      target=3,
                                      angle=math.pi / 2,
                                      turnType=TurnType.Z,
                                      dic=dic)

    # imprime por pantalla el path
    print(
        Visualizer.printCompress(gateId,
                                 dic,
                                 deepEnd=True,
                                 deep=1,
                                 autoReference=False))

    # genera el fichero .qasm para crear esta puerta
    WriterAsm.writeAsm(gateId, dic, "multiConditionalGate.qasm", reset=True)

    Debug.debug(Visualizer.printCompress(
        id,
        dic,
    ), DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=True,
                                 deep=1,
                                 autoReference=True), DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=True,
                                 deep=2,
                                 autoReference=True), DebugLevel.Debug)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)
Example #12
0
def xnotGateTest():

    dic = DictionarySearcher(2)

    id = AQP.generateXnot(target=1, source=0, dic=dic)
    Debug.debug(Visualizer.printPath(id, dic), DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        "\n" + Visualizer.printIntegerMatrix(dic.getGate(id).getMatrix()) +
        "\n\n", DebugLevel.Result)

    id = AQP.generateXnot(target=0, source=1, dic=dic)
    Debug.debug(Visualizer.printPath(id, dic), DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        "\n" + Visualizer.printIntegerMatrix(dic.getGate(id).getMatrix()) +
        "\n\n", DebugLevel.Result)

    dic = DictionarySearcher(3)

    id = AQP.generateXnot(target=1, source=0, dic=dic)
    Debug.debug(Visualizer.printPath(id, dic), DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        "\n" + Visualizer.printIntegerMatrix(dic.getGate(id).getMatrix()) +
        "\n\n", DebugLevel.Result)

    id = AQP.generateXnot(target=0, source=1, dic=dic)
    Debug.debug(Visualizer.printPath(id, dic), DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        "\n" + Visualizer.printIntegerMatrix(dic.getGate(id).getMatrix()) +
        "\n\n", DebugLevel.Result)

    id = AQP.generateXnot(target=2, source=1, dic=dic)
    Debug.debug(Visualizer.printPath(id, dic), DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        "\n" + Visualizer.printIntegerMatrix(dic.getGate(id).getMatrix()) +
        "\n\n", DebugLevel.Result)

    dic = DictionarySearcher(4)

    id = AQP.generateXnot(target=3, source=0, dic=dic)
    Debug.debug(Visualizer.printPath(id, dic), DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        "\n" + Visualizer.printIntegerMatrix(dic.getGate(id).getMatrix()) +
        "\n\n", DebugLevel.Result)

    id = AQP.generateXnot(target=2, source=1, dic=dic)
    Debug.debug(Visualizer.printPath(id, dic), DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        "\n" + Visualizer.printIntegerMatrix(dic.getGate(id).getMatrix()) +
        "\n\n", DebugLevel.Result)

    id = AQP.generateXnot(target=1, source=2, dic=dic)
    Debug.debug(Visualizer.printPath(id, dic), DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        "\n" + Visualizer.printIntegerMatrix(dic.getGate(id).getMatrix()) +
        "\n\n", DebugLevel.Result)
Example #13
0
def groverMatricesTest():

    Debug.debug(QuantumMath.getOracleMatrix(2, [3]), DebugLevel.Result)
    Debug.debug(QuantumMath.getOracleMatrix(3, [3, 4, 5]), DebugLevel.Result)

    matrix = QuantumMath.getAmplitudAmplifier(2)
    Debug.debug(matrix, DebugLevel.Result)
    Debug.debug(QuantumMath.matrixDeterminant(matrix), DebugLevel.Info)

    matrix = QuantumMath.getAmplitudAmplifier(3)
    Debug.debug(matrix, DebugLevel.Result)
    Debug.debug(QuantumMath.matrixDeterminant(matrix), DebugLevel.Info)

    matrix = QuantumMath.getAmplitudAmplifier(4)
    Debug.debug(matrix, DebugLevel.Result)
    Debug.debug(QuantumMath.matrixDeterminant(matrix), DebugLevel.Info)
Example #14
0
def specialTest():

    dic = DictionarySearcher(2)

    matrix = np.matrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0],
                        [0, 0, 0, -1]])
    id = AQP.generateSpecial(matrix=matrix, name="prueba1", dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=True,
                                 deep=1,
                                 autoReference=True), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)

    matrix = np.matrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0],
                        [0, 0, 0, 1j]])
    id = AQP.generateSpecial(matrix=matrix, name="prueba2", dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=True,
                                 deep=1,
                                 autoReference=True), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)

    matrix = np.matrix([[-1, 0, 0, 0], [0, 1, 0, 0],
                        [0, 0, (1 / math.sqrt(2)) * (1 + 1j), 0],
                        [0, 0, 0, 1j]])
    id = AQP.generateSpecial(matrix=matrix, name="prueba3", dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=True,
                                 deep=1,
                                 autoReference=True), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)

    matrix = np.matrix([[1j, 0, 0, 0],
                        [0, (1 / math.sqrt(2)), (-1 / math.sqrt(2)), 0],
                        [0, (1 / math.sqrt(2)), (1 / math.sqrt(2)), 0],
                        [0, 0, 0, -1]])
    id = AQP.generateSpecial(matrix=matrix, name="prueba4", dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=True,
                                 deep=1,
                                 autoReference=True), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)
    """
    Debug.debug("\n" + str(dic.getGate(67).getMatrix()) + "\n\n", DebugLevel.Result) 
    Debug.debug("\n" + str(dic.getGate(68).getMatrix()) + "\n\n", DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(78).getMatrix()) + "\n\n", DebugLevel.Result) 
    Debug.debug("\n" + str(dic.getGate(68).getMatrix()) + "\n\n", DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(67).getMatrix()) + "\n\n", DebugLevel.Result) 
    Debug.debug("\n" + str(AQP.generateMatrixFromPath([68,67,78,67,68], dic)) + "\n\n", DebugLevel.Result)
    """

    matrix = np.matrix([[-1, 1, 1, 1], [1, -1, 1, 1], [1, 1, -1, 1],
                        [1, 1, 1, -1]]) * (1 / 2)
    id = AQP.generateSpecial(matrix=matrix, name="prueba5", dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=True,
                                 deep=1,
                                 autoReference=True), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)

    dic = DictionarySearcher(3)

    matrix = np.eye(2**3, dtype=complex)
    matrix[7, 7] = -1
    id = AQP.generateSpecial(matrix=matrix, name="prueba6", dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=True,
                                 deep=1,
                                 autoReference=True), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)

    matrix[5, 6] = 1
    matrix[6, 5] = 1
    matrix[5, 5] = 0
    matrix[6, 6] = 0
    id = AQP.generateSpecial(matrix=matrix, name="prueba67", dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=True,
                                 deep=1,
                                 autoReference=True), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)
Example #15
0
def toBinaryTest():

    Debug.debug(QuantumMath.toBinary(5, 3), DebugLevel.Result)
    Debug.debug(QuantumMath.toBinary(5, 5), DebugLevel.Result)
    Debug.debug(QuantumMath.toBinary(16, 6), DebugLevel.Result)
    Debug.debug(QuantumMath.toBinary(31, 6), DebugLevel.Result)
Example #16
0
def codingDecodingTest():

    aux = QuantumMath.codingQubits([0, 1, 2])
    Debug.debug(aux, DebugLevel.Result)
    Debug.debug(QuantumMath.decodingQubits(aux), DebugLevel.Result)

    aux = QuantumMath.codingQubits([1, 4])
    Debug.debug(aux, DebugLevel.Result)
    Debug.debug(QuantumMath.decodingQubits(aux), DebugLevel.Result)

    aux = QuantumMath.codingQubits([6])
    Debug.debug(aux, DebugLevel.Result)
    Debug.debug(QuantumMath.decodingQubits(aux), DebugLevel.Result)
Example #17
0
def basicTurnGateTest():

    dic = DictionarySearcher(2)

    id = AQP.generateBasicTurn(target=1,
                               angle=math.pi,
                               turnType=TurnType.Z,
                               dic=dic)
    Debug.debug(Visualizer.printPath(id, dic), DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)

    id = AQP.generateBasicTurn(target=0,
                               angle=math.pi / 2,
                               turnType=TurnType.Z,
                               dic=dic)
    Debug.debug(Visualizer.printPath(id, dic), DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)

    id = AQP.generateBasicTurn(target=1,
                               angle=math.pi / 4,
                               turnType=TurnType.X,
                               dic=dic)
    Debug.debug(Visualizer.printPath(id, dic), DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)

    dic = DictionarySearcher(4)

    id = AQP.generateBasicTurn(target=3,
                               angle=math.pi / 4,
                               turnType=TurnType.Z,
                               dic=dic)
    Debug.debug(Visualizer.printPath(id, dic), DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)

    id = AQP.generateBasicTurn(target=1,
                               angle=math.pi / 4,
                               turnType=TurnType.Z,
                               dic=dic)
    Debug.debug(Visualizer.printPath(id, dic), DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)
Example #18
0
def specialTurnGateTest():

    dic = DictionarySearcher(2)

    id = AQP.generateSpecialTurn(a=-1, b=0, dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)

    id = AQP.generateSpecialTurn(a=(1 / (math.sqrt(2))),
                                 b=(1 / (math.sqrt(2))),
                                 dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)

    dic = DictionarySearcher(3)

    id = AQP.generateSpecialTurn(a=1j, b=0, dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=True,
                                 deep=1,
                                 autoReference=True), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)

    dic = DictionarySearcher(4)

    id = AQP.generateSpecialTurn(a=(1 / (math.sqrt(2))),
                                 b=(1j * (1 / (math.sqrt(2)))),
                                 dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=True,
                                 deep=1,
                                 autoReference=True), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)
Example #19
0
def rowReverseGateTest():

    dic = DictionarySearcher(2)

    id = AQP.generateRowReverse(target1=0, target2=3, dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=True,
                                 deep=1,
                                 autoReference=True), DebugLevel.Result)
    Debug.debug(
        "\n" + Visualizer.printIntegerMatrix(dic.getGate(id).getMatrix()) +
        "\n\n", DebugLevel.Result)

    id = AQP.generateRowReverse(target1=2, target2=1, dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=True,
                                 deep=1,
                                 autoReference=True), DebugLevel.Result)
    Debug.debug(
        "\n" + Visualizer.printIntegerMatrix(dic.getGate(id).getMatrix()) +
        "\n\n", DebugLevel.Result)

    id = AQP.generateRowReverse(target1=1, target2=2, dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=True,
                                 deep=1,
                                 autoReference=True), DebugLevel.Result)
    Debug.debug(
        "\n" + Visualizer.printIntegerMatrix(dic.getGate(id).getMatrix()) +
        "\n\n", DebugLevel.Result)

    dic = DictionarySearcher(3)

    id = AQP.generateRowReverse(target1=0, target2=3, dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=True,
                                 deep=1,
                                 autoReference=True), DebugLevel.Result)
    Debug.debug(
        "\n" + Visualizer.printIntegerMatrix(dic.getGate(id).getMatrix()) +
        "\n\n", DebugLevel.Result)

    id = AQP.generateRowReverse(target1=1, target2=7, dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=True,
                                 deep=1,
                                 autoReference=True), DebugLevel.Result)
    Debug.debug(
        "\n" + Visualizer.printIntegerMatrix(dic.getGate(id).getMatrix()) +
        "\n\n", DebugLevel.Result)

    id = AQP.generateRowReverse(target1=4, target2=2, dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=True,
                                 deep=1,
                                 autoReference=True), DebugLevel.Result)
    Debug.debug(
        "\n" + Visualizer.printIntegerMatrix(dic.getGate(id).getMatrix()) +
        "\n\n", DebugLevel.Result)
Example #20
0
def multipleTurnGateTest():

    dic = DictionarySearcher(2)

    id = AQP.generateMultipleTurn(sources=[0],
                                  target=1,
                                  angle=math.pi,
                                  turnType=TurnType.Z,
                                  dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id, dic, deepEnd=False, autoReference=True),
        DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)

    dic = DictionarySearcher(3)

    id = AQP.generateMultipleTurn(sources=[0, 1],
                                  target=2,
                                  angle=math.pi,
                                  turnType=TurnType.Z,
                                  dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=True,
                                 deep=1,
                                 autoReference=True), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)

    id = AQP.generateMultipleTurn(sources=[0, 1],
                                  target=2,
                                  angle=math.pi / 4,
                                  turnType=TurnType.X,
                                  dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)

    id = AQP.generateMultipleTurn(sources=[0, 2],
                                  target=1,
                                  angle=math.pi / 4,
                                  turnType=TurnType.X,
                                  dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=False,
                                 deep=1,
                                 autoReference=True), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)

    Debug.debug("\n" + str(dic) + "\n\n", DebugLevel.Result)

    dic = DictionarySearcher(4)

    id = AQP.generateMultipleTurn(sources=[0, 1, 2],
                                  target=3,
                                  angle=math.pi / 2,
                                  turnType=TurnType.X,
                                  dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=True,
                                 deep=1,
                                 autoReference=True), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)

    id = AQP.generateMultipleTurn(sources=[0, 1, 2],
                                  target=3,
                                  angle=math.pi,
                                  turnType=TurnType.Z,
                                  dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)

    id = AQP.generateMultipleTurn(sources=[2],
                                  target=0,
                                  angle=math.pi / 4,
                                  turnType=TurnType.X,
                                  dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)
Example #21
0
    def _init_state_manager(self):
        """"""
        dbg.debug(print, "Init State", debug=self._gs['debug'])

        # Parse config file
        self._parse_config_file()

        # Init directory
        self._init_output_directory()

        # Init SX5
        self._init_sx5()

        # Init Temperature Sensor
        self._init_temperature_sensor()

        # Init Image Manager
        self._init_image_manager()

        # Init Timers
        self._init_timers()

        # Init Step Dictionary
        self._init_step_dictionary()

        # Update Directories
        self._update_directories()

        # Init Threads
        self._scan_engine_app_thread = CustomThread(
            thread_name="ScanEngineThread",
            runnable=self._SX5.run_scan_engine_app,
            num_of_iter=1)

        self._read_temperature_thread = CustomThread(
            thread_name="ReadTemperatureThread",
            runnable=self._read_temperature_sensor_thread_runnable,
            timing_ms=500,
            num_of_iter='inf')

        self._csv_log_thread = CustomThread(
            thread_name="CsvLogThread",
            runnable=self._update_csv_log_runnable,
            timing_ms=float(self._config_dict["Log"]["sample_time_s"]) * 1000,
            num_of_iter='inf')

        # Create CSV Log file
        self._csv_log_dict['filename'] = self._config_dict['SX5'][
            'output_dir_name'] + "/" + self._config_dict['Log']['csv_filename']
        self._csv_log_dict['file'] = open(file=self._csv_log_dict['filename'],
                                          mode='w',
                                          newline='')
        self._csv_log_dict['csv_writer'] = csv.writer(
            self._csv_log_dict['file'])
        self._csv_log_dict['csv_writer'].writerow(
            self._csv_log_dict["log_data"].keys())
        self._csv_log_dict['file'].close()

        # Go to Run scan engine app state
        self._SX5.clear_frame_storage_dir()
        self._temp_test_state = enum.TempTestTS_StatesEnum.TT_RUN_SCAN_ENGINE_APP

        return
Example #22
0
 def _error_state_manager(self):
     """"""
     dbg.debug(print, "Error State", debug=self._gs['debug'])
     self._temp_test_state = enum.TempTestStatesEnum.TT_STOP
     pass
Example #23
0
 def _stop_state_manager(self):
     """"""
     dbg.debug(print, "Stop State", debug=self._gs['debug'])
     print("-Finished!")
     pass
Example #24
0
def assemblerGetPathTest():

    dic = DictionarySearcher(2)
    matrix = QuantumMath.getOracleMatrix(2, [0])
    id = AQP.generateSpecial(matrix=matrix, name="asmPath1", dic=dic)

    Debug.debug(Visualizer.printCompress(
        id,
        dic,
    ), DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=True,
                                 deep=1,
                                 autoReference=True), DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=True,
                                 deep=2,
                                 autoReference=True), DebugLevel.Debug)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)

    Debug.debug(WriterAsm.getPath(id, dic), DebugLevel.Result)

    dic = DictionarySearcher(2)
    matrix = QuantumMath.getAmplitudAmplifier(2)
    id = AQP.generateSpecial(matrix=matrix, name="asmPath2", dic=dic)

    Debug.debug(Visualizer.printCompress(
        id,
        dic,
    ), DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=True,
                                 deep=1,
                                 autoReference=True), DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=True,
                                 deep=2,
                                 autoReference=True), DebugLevel.Debug)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)

    Debug.debug(WriterAsm.getPath(id, dic), DebugLevel.Result)
Example #25
0
def basicGateTest():

    dic = DictionarySearcher(2)

    id = AQP.generateBasic(standarGate=StandarGate.X, targets=[0], dic=dic)
    Debug.debug(Visualizer.printPath(id, dic), DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)

    id = AQP.generateBasic(standarGate=StandarGate.X, targets=[0, 1], dic=dic)
    Debug.debug(Visualizer.printPath(id, dic), DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)

    id = AQP.generateBasic(standarGate=StandarGate.H, targets=[0, 1], dic=dic)
    Debug.debug(Visualizer.printPath(id, dic), DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)

    dic = DictionarySearcher(4)

    id = AQP.generateBasic(standarGate=StandarGate.X,
                           targets=[1, 2, 3],
                           dic=dic)
    Debug.debug(Visualizer.printPath(id, dic), DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)

    id = AQP.generateBasic(standarGate=StandarGate.H, targets=[2], dic=dic)
    Debug.debug(Visualizer.printPath(id, dic), DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)
Example #26
0
class Debug(object):
    def __init__(self):
        pass

    @staticmethod
    def debug(function, *args, debug):
        if debug == True:
            function(*args)

        pass


if __name__ == '__main__':
    from Debug import Debug as db

    flag = True

    db.debug(print, "Print if true", debug=flag)

    db.debug(print, "Don't print if false", debug=not flag)
Example #27
0
def toffoliGateTest():

    dic = DictionarySearcher(3)

    id = AQP.generateToffoli(target=2, sources=[0, 1], dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        "\n" + Visualizer.printIntegerMatrix(dic.getGate(id).getMatrix()) +
        "\n\n", DebugLevel.Result)

    id = AQP.generateToffoli(target=1, sources=[0, 2], dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        "\n" + Visualizer.printIntegerMatrix(dic.getGate(id).getMatrix()) +
        "\n\n", DebugLevel.Result)

    dic = DictionarySearcher(4)

    id = AQP.generateToffoli(target=3, sources=[0, 1, 2], dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        Visualizer.printCompress(id,
                                 dic,
                                 deepEnd=True,
                                 deep=2,
                                 autoReference=True), DebugLevel.Result)
    Debug.debug("\n" + str(dic.getGate(id).getMatrix()) + "\n\n",
                DebugLevel.Result)
    Debug.debug(
        "\n" + Visualizer.printIntegerMatrix(dic.getGate(id).getMatrix()) +
        "\n\n", DebugLevel.Result)

    id = AQP.generateToffoli(target=3, sources=[0, 2], dic=dic)
    Debug.debug(Visualizer.printPath(id, dic, deepEnd=False),
                DebugLevel.Result)
    Debug.debug(Visualizer.printCompress(id, dic), DebugLevel.Result)
    Debug.debug(
        "\n" + Visualizer.printIntegerMatrix(dic.getGate(id).getMatrix()) +
        "\n\n", DebugLevel.Result)