source: sasmodels/sasmodels/kernel.py @ a5b8477

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since a5b8477 was a5b8477, checked in by Paul Kienzle <pkienzle@…>, 8 years ago

update docs to work with the new ModelInfo/ParameterTable? classes

  • Property mode set to 100644
File size: 1.3 KB
Line 
1"""
2Execution kernel interface
3==========================
4
5:class:`KernelModel` defines the interface to all kernel models.
6In particular, each model should provide a :meth:`KernelModel.make_kernel`
7call which returns an executable kernel, :class:`Kernel`, that operates
8on the given set of *q_vector* inputs.  On completion of the computation,
9the kernel should be released, which also releases the inputs.
10"""
11
12try:
13    from typing import List
14    from .details import CallDetails
15    from .modelinfo import ModelInfo
16    import numpy as np  # type: ignore
17except ImportError:
18    pass
19
20class KernelModel(object):
21    info = None  # type: ModelInfo
22    dtype = None # type: np.dtype
23    def make_kernel(self, q_vectors):
24        # type: (List[np.ndarray]) -> "Kernel"
25        raise NotImplementedError("need to implement make_kernel")
26
27    def release(self):
28        # type: () -> None
29        pass
30
31class Kernel(object):
32    #: kernel dimension, either "1d" or "2d"
33    dim = None  # type: str
34    info = None  # type: ModelInfo
35    results = None # type: List[np.ndarray]
36
37    def __call__(self, call_details, weights, values, cutoff):
38        # type: (CallDetails, np.ndarray, np.ndarray, float) -> np.ndarray
39        raise NotImplementedError("need to implement __call__")
40
41    def release(self):
42        # type: () -> None
43        pass
Note: See TracBrowser for help on using the repository browser.