-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added basic skeleton of a qiskit backend
- Loading branch information
1 parent
daed76a
commit 644e5c1
Showing
4 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .provider import Provider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from .job import Job | ||
from qiskit import qobj | ||
|
||
|
||
class TestSimulator(): | ||
|
||
def __init__(self, configuration=None, provider=None, **fields): | ||
pass | ||
# super().__init__(configuration=configuration, provider=provider, **fields) | ||
|
||
def run(self, qobj: qobj.Qobj, **backend_options): | ||
job_id = 123 | ||
job = Job(self, job_id, self._run_job(job_id, qobj)) | ||
return job | ||
|
||
def _run_job(self, job_id, qobj): | ||
test_ret = { | ||
"success": True, | ||
"data": [1, 0, 0] | ||
} | ||
return test_ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
class Job(): | ||
|
||
def __init__(self, backend, job_id, result): | ||
# super().__init__(backend, job_id) | ||
self._result = result | ||
|
||
def result(self): | ||
return self._result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from qiskit.providers.provider import ProviderV1 as QiskitProvider | ||
from .backend import TestSimulator | ||
|
||
SIMULATORS = [TestSimulator] | ||
|
||
|
||
class Provider(QiskitProvider): | ||
|
||
def __init__(self): | ||
super().__init__() | ||
|
||
self.name = "qutip_provider" | ||
self._backends = {"test_backend": TestSimulator()} | ||
|
||
def backends(self, name=None, filters=None, **kwargs): | ||
backends = list(self._backends.values()) | ||
if name: | ||
try: | ||
backends = [self._backends[name]] | ||
except LookupError: | ||
print("The '{}' backend is not installed in your system.".format(name)) | ||
|
||
return backends |