source: sasmodels/sasmodels/kernel.py @ ef07e95

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since ef07e95 was 2d81cfe, checked in by Paul Kienzle <pkienzle@…>, 6 years ago

lint

  • Property mode set to 100644
File size: 1.5 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
12from __future__ import division, print_function
13
14# pylint: disable=unused-import
15try:
16    from typing import List
17except ImportError:
18    pass
19else:
20    import numpy as np
21    from .details import CallDetails
22    from .modelinfo import ModelInfo
23# pylint: enable=unused-import
24
25class 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
36class 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
Note: See TracBrowser for help on using the repository browser.