|
| 1 | +"""Quantum Inspire SDK. |
| 2 | +
|
| 3 | +Copyright 2022 QuTech Delft |
| 4 | +
|
| 5 | +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the |
| 6 | +License. You may obtain a copy of the License at |
| 7 | +
|
| 8 | +https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an |
| 11 | +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific |
| 12 | +language governing permissions and limitations under the License. |
| 13 | +""" |
| 14 | + |
| 15 | +from abc import ABC, abstractmethod |
| 16 | +from typing import Any, Dict, List |
| 17 | + |
| 18 | +from compute_api_client.models.backend_type import BackendType |
| 19 | +from pydantic import BaseModel |
| 20 | + |
| 21 | + |
| 22 | +class ExecuteCircuitResult(BaseModel): |
| 23 | + """Result of executing a quantum circuit.""" |
| 24 | + |
| 25 | + results: Dict[str, float] |
| 26 | + shots_requested: int |
| 27 | + shots_done: int |
| 28 | + |
| 29 | + |
| 30 | +class QuantumInterface(ABC): |
| 31 | + """Interface for running quantum circuits from hybrid algorithms.""" |
| 32 | + |
| 33 | + # pylint: disable = R0903 |
| 34 | + # Too few public methods (1/2) (too-few-public-methods) |
| 35 | + |
| 36 | + results: List[Dict[str, Any]] |
| 37 | + backend_type: BackendType |
| 38 | + |
| 39 | + @abstractmethod |
| 40 | + def execute_circuit( |
| 41 | + self, circuit: str, number_of_shots: int |
| 42 | + ) -> ExecuteCircuitResult: |
| 43 | + """Execute a quantum circuit.""" |
| 44 | + raise NotImplementedError |
0 commit comments