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 | |
---|
12 | from __future__ import division, print_function |
---|
13 | |
---|
14 | # pylint: disable=unused-import |
---|
15 | try: |
---|
16 | from typing import List |
---|
17 | except ImportError: |
---|
18 | pass |
---|
19 | else: |
---|
20 | import numpy as np |
---|
21 | from .details import CallDetails |
---|
22 | from .modelinfo import ModelInfo |
---|
23 | # pylint: enable=unused-import |
---|
24 | |
---|
25 | class KernelModel(object): |
---|
26 | info = None # type: ModelInfo |
---|
27 | dtype = None # type: np.dtype |
---|
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] |
---|
41 | dtype = None # type: np.dtype |
---|
42 | |
---|
43 | def __call__(self, call_details, values, cutoff, magnetic): |
---|
44 | # type: (CallDetails, np.ndarray, np.ndarray, float, bool) -> np.ndarray |
---|
45 | raise NotImplementedError("need to implement __call__") |
---|
46 | |
---|
47 | def release(self): |
---|
48 | # type: () -> None |
---|
49 | pass |
---|