コード例 #1
0
 def test_pyquil_commands(self):
     wrapper = CircuitWrapper(
         qiskit_circuit=grover_general_logicalexpression_qiskit(
             "(A | B) & (A | ~B) & (~A | B)"))
     print(wrapper.circuit)
     commands = wrapper.export_pyquil_commands()
     print(commands)
コード例 #2
0
def convert():
    data = request.json
    option = data["option"]
    option_output = data["optionOutput"]
    circuit = data["circuit"]
    try:
        if option.lower() == "quil":
            wrapper = CircuitWrapper(quil_str=circuit)
        elif option.lower() == "pyquil":
            wrapper = CircuitWrapper(pyquil_instructions=circuit)
        elif option.lower() == "openqasm":
            wrapper = CircuitWrapper(qasm=circuit)
        elif option.lower() == "qiskit":
            wrapper = CircuitWrapper(qiskit_instructions=circuit)
        else:
            return "Bad Request!", 400

        if option_output.lower() == "quil":
            output = wrapper.export_quil()
        elif option_output.lower() == "pyquil":
            output = wrapper.export_pyquil_commands()
        elif option_output.lower() == "openqasm":
            output = wrapper.export_qasm()
        elif option_output.lower() == "qiskit":
            output = wrapper.export_qiskit_commands(include_imports=True)
        else:
            return "Bad Request!", 400
    except Exception as e:
        print(str(e))
        return str(e), 500

    return output
コード例 #3
0
def unroll():
    data = request.json
    option = data["option"]
    circuit = data["circuit"]
    isExpert = data["isExpert"]
    format = data["format"]

    try:
        wrapper = CircuitWrapper(qiskit_instructions=circuit)
        if option == "Rigetti":
            wrapper.unroll_rigetti()
        elif option == "IBMQ":
            wrapper.unroll_ibm()
        else:
            return "Bad Request!", 400

        if isExpert:
            if format == "OpenQASM":
                output = wrapper.export_qasm()
            elif format == "Quil":
                output = wrapper.export_quil()
            elif format == "Qiskit":
                output = wrapper.export_qiskit_commands(include_imports=True)
            elif format == "Pyquil":
                output = wrapper.export_pyquil_commands()
            else:
                return "Bad Request!", 400
        else:
            if option == "Rigetti":
                output = wrapper.export_quil()
            elif option == "IBMQ":
                output = wrapper.export_qasm()
            else:
                return "Bad Request!", 400

    except Exception as e:
        print(str(e))
        return str(e), 500
    return output