How to use the quantuminspire.exceptions.ProjectQBackendError 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 / projectq / backend_qx.py View on Github external
Sets self._quantum_inspire_result with the result object in the API response.

        Raises:
            ProjectQBackendError: when raw_text in result from API is not empty (indicating a backend error).
        """
        self._quantum_inspire_result = self._quantum_inspire_api.execute_qasm(
            self._cqasm,
            number_of_shots=self._num_runs,
            backend_type=self._backend_type,
            full_state_projection=self._full_state_projection
        )

        if not self._quantum_inspire_result.get('histogram', {}):
            raw_text = self._quantum_inspire_result.get('raw_text', 'no raw_text in result structure')
            raise ProjectQBackendError(
                f'Result structure does not contain proper histogram. raw_text field: {raw_text}')
github QuTech-Delft / quantuminspire / src / quantuminspire / projectq / backend_qx.py View on Github external
self._verbose: int = verbose
        self._cqasm: str = str()
        self._measured_states: Dict[int, float] = {}
        self._measured_ids: List[int] = []
        self._allocation_map: List[Tuple[int, int]] = []
        self._max_qubit_id: int = -1
        if quantum_inspire_api is None:
            try:
                quantum_inspire_api = QuantumInspireAPI()
            except AuthenticationError as ex:
                raise AuthenticationError('Make sure you have saved your token credentials on disk or '
                                          'provide a QuantumInspireAPI instance as parameter to QIBackend') from ex
        self._quantum_inspire_api: QuantumInspireAPI = quantum_inspire_api
        self._backend_type: Dict[str, Any] = self._quantum_inspire_api.get_backend_type(backend_type)
        if num_runs < 1 or num_runs > self._backend_type['max_number_of_shots']:
            raise ProjectQBackendError(f'Invalid number of runs (num_runs={num_runs})')
        self._num_runs: int = num_runs
        self._full_state_projection = not self._backend_type["is_hardware_backend"]
        self._is_simulation_backend = not self._backend_type["is_hardware_backend"]
        self._max_number_of_qubits: int = self._backend_type["number_of_qubits"]
        self._one_qubit_gates: Tuple[Any, ...] = self._get_one_qubit_gates()
        self._two_qubit_gates: Tuple[Any, ...] = self._get_two_qubit_gates()
        self._three_qubit_gates: Tuple[Any, ...] = self._get_three_qubit_gates()