[f619de7] | 1 | """ |
---|
| 2 | Execution kernel interface |
---|
| 3 | ========================== |
---|
| 4 | |
---|
| 5 | :class:`KernelModel` defines the interface to all kernel models. |
---|
| 6 | In particular, each model should provide a :meth:`KernelModel.make_kernel` |
---|
| 7 | call which returns an executable kernel, :class:`Kernel`, that operates |
---|
| 8 | on the given set of *q_vector* inputs. On completion of the computation, |
---|
| 9 | the kernel should be released, which also releases the inputs. |
---|
| 10 | """ |
---|
| 11 | |
---|
[a738209] | 12 | from __future__ import division, print_function |
---|
| 13 | |
---|
[0ff62d4] | 14 | import numpy as np |
---|
| 15 | |
---|
[f619de7] | 16 | try: |
---|
| 17 | from typing import List |
---|
[0ff62d4] | 18 | except ImportError: |
---|
| 19 | pass |
---|
| 20 | else: |
---|
[f619de7] | 21 | from .details import CallDetails |
---|
| 22 | from .modelinfo import ModelInfo |
---|
[7ae2b7f] | 23 | import numpy as np # type: ignore |
---|
[f619de7] | 24 | |
---|
| 25 | class KernelModel(object): |
---|
[04dc697] | 26 | info = None # type: ModelInfo |
---|
[a5b8477] | 27 | dtype = None # type: np.dtype |
---|
[f619de7] | 28 | def make_kernel(self, q_vectors): |
---|
| 29 | # type: (List[np.ndarray]) -> "Kernel" |
---|
| 30 | raise NotImplementedError("need to implement make_kernel") |
---|
| 31 | |
---|
| 32 | def release(self): |
---|
| 33 | # type: () -> None |
---|
| 34 | pass |
---|
| 35 | |
---|
| 36 | class Kernel(object): |
---|
| 37 | #: kernel dimension, either "1d" or "2d" |
---|
| 38 | dim = None # type: str |
---|
| 39 | info = None # type: ModelInfo |
---|
| 40 | results = None # type: List[np.ndarray] |
---|
[bde38b5] | 41 | dtype = None # type: np.dtype |
---|
[f619de7] | 42 | |
---|
[32e3c9b] | 43 | def __call__(self, call_details, values, cutoff, magnetic): |
---|
| 44 | # type: (CallDetails, np.ndarray, np.ndarray, float, bool) -> np.ndarray |
---|
[f619de7] | 45 | raise NotImplementedError("need to implement __call__") |
---|
| 46 | |
---|
| 47 | def release(self): |
---|
| 48 | # type: () -> None |
---|
| 49 | pass |
---|