How to use the quantuminspire.qiskit.circuit_parser.CircuitToString function in quantuminspire

To help you get started, we’ve selected a few quantuminspire examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github QuTech-Delft / quantuminspire / src / quantuminspire / qiskit / backend_qx.py View on Github external
def _generate_cqasm(experiment: QasmQobjExperiment, full_state_projection: bool = True) -> str:
        """ Generates the cQASM from the Qiskit experiment.

        Args:
            experiment: The experiment that contains instructions to be converted to cQASM.
            full_state_projection: When False, the experiment is not suitable for full state projection

        Returns:
            The cQASM code that can be sent to the Quantum Inspire API.
        """
        parser = CircuitToString(full_state_projection)
        number_of_qubits = experiment.header.n_qubits
        instructions = experiment.instructions
        with io.StringIO() as stream:
            stream.write('version 1.0\n')
            stream.write('# cQASM generated by QI backend for Qiskit\n')
            stream.write('qubits %d\n' % number_of_qubits)
            for instruction in instructions:
                parser.parse(stream, instruction)
            return stream.getvalue()