Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from qiskit.qobj import QasmQobj, QasmQobjExperiment
from qiskit.result.models import ExperimentResult, ExperimentResultData
from qiskit.validation.base import Obj
from quantuminspire.api import QuantumInspireAPI
from quantuminspire.exceptions import QisKitBackendError
from quantuminspire.job import QuantumInspireJob
from quantuminspire.qiskit.circuit_parser import CircuitToString
from quantuminspire.qiskit.qi_job import QIJob
from quantuminspire.version import __version__ as quantum_inspire_version
class QuantumInspireBackend(BaseBackend): # type: ignore
DEFAULT_CONFIGURATION = QasmBackendConfiguration(
backend_name='qi_simulator',
backend_version=quantum_inspire_version,
n_qubits=26,
basis_gates=['x', 'y', 'z', 'h', 'rx', 'ry', 'rz', 's', 'sdg', 't', 'tdg', 'cx', 'ccx', 'u1', 'u2', 'u3', 'id',
'swap', 'cz', 'snapshot'],
gates=[GateConfig(name='NotUsed', parameters=['NaN'], qasm_def='NaN')],
local=False,
simulator=True,
conditional=True,
open_pulse=False,
memory=True,
max_shots=1024,
max_experiments=1,
coupling_map=None
)
def __init__(self, api: QuantumInspireAPI, provider: Any,
configuration: Optional[QasmBackendConfiguration] = None) -> None:
Returns:
Result object containing results from the experiments.
Raises:
JobTimeoutError: If timeout is reached.
QisKitBackendError: If an error occurs during simulation.
"""
start_time = time.time()
while self.status() not in JOB_FINAL_STATES:
elapsed_time = time.time() - start_time
if timeout is not None and elapsed_time > timeout:
raise JobTimeoutError('Failed getting result: timeout reached.')
time.sleep(wait)
experiment_results = self._backend.get_experiment_results(self)
return Result(backend_name=self._backend.backend_name, backend_version=quantum_inspire_version,
job_id=self.job_id(), qobj_id=self.job_id(), success=True, results=experiment_results)