Changeset e62a134 in sasmodels
- Timestamp:
- Apr 8, 2016 6:48:35 PM (9 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 49d2308
- Parents:
- 0d99a6a
- Location:
- sasmodels
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/kernelpy.py
r4bfd277 re62a134 12 12 from . import details 13 13 from .generate import F64 14 15 try: 16 from typing import Union 17 except: 18 pass 19 else: 20 DType = Union[None, str, np.dtype] 14 21 15 22 class PyModel(object): -
sasmodels/model_test.py
r4bfd277 re62a134 58 58 from .modelinfo import expand_pars 59 59 60 try: 61 from typing import List, Iterator, Callable 62 except ImportError: 63 pass 64 else: 65 from .modelinfo import ParameterTable, ParameterSet, TestCondition, ModelInfo 66 from .kernelpy import PyModel, PyInput, PyKernel, DType 67 60 68 def call_ER(model_info, pars): 69 # type: (ModelInfo, ParameterSet) -> float 61 70 """ 62 71 Call the model ER function using *values*. *model_info* is either … … 72 81 73 82 def call_VR(model_info, pars): 83 # type: (ModelInfo, ParameterSet) -> float 74 84 """ 75 85 Call the model VR function using *pars*. … … 85 95 86 96 def _vol_pars(model_info, pars): 97 # type: (ModelInfo, ParameterSet) -> Tuple[np.ndarray, np.ndarray] 87 98 vol_pars = [get_weights(p, pars) 88 99 for p in model_info.parameters.call_parameters … … 93 104 94 105 def make_suite(loaders, models): 106 # type: (List[str], List[str]) -> unittest.TestSuite 95 107 """ 96 108 Construct the pyunit test suite. … … 102 114 *models* is the list of models to test, or *["all"]* to test all models. 103 115 """ 104 105 ModelTestCase = _hide_model_case_from_nosetests() 116 ModelTestCase = _hide_model_case_from_nose() 106 117 suite = unittest.TestSuite() 107 118 … … 160 171 161 172 162 def _hide_model_case_from_nosetests(): 173 def _hide_model_case_from_nose(): 174 # type: () -> type 163 175 class ModelTestCase(unittest.TestCase): 164 176 """ … … 171 183 def __init__(self, test_name, model_info, test_method_name, 172 184 platform, dtype): 185 # type: (str, ModelInfo, str, str, DType) -> None 173 186 self.test_name = test_name 174 187 self.info = model_info … … 180 193 181 194 def run_all(self): 195 # type: () -> None 182 196 smoke_tests = [ 183 [{}, 0.1, None],184 [{}, (0.1, 0.1), None],185 [{}, 'ER', None],186 [{}, 'VR', None],197 ({}, 0.1, None), 198 ({}, (0.1, 0.1), None), 199 ({}, 'ER', None), 200 ({}, 'VR', None), 187 201 ] 188 202 … … 207 221 208 222 def run_one(self, model, test): 209 pars, x, y = test 210 pars = expand_pars(self.info.parameters, pars) 223 # type: (PyModel, TestCondition) -> None 224 user_pars, x, y = test 225 pars = expand_pars(self.info.parameters, user_pars) 211 226 212 227 if not isinstance(y, list): … … 222 237 actual = [call_VR(model.info, pars)] 223 238 elif isinstance(x[0], tuple): 224 Qx, Qy = zip(*x)225 q_vectors = [np.array( Qx), np.array(Qy)]239 qx, qy = zip(*x) 240 q_vectors = [np.array(qx), np.array(qy)] 226 241 kernel = model.make_kernel(q_vectors) 227 242 actual = call_kernel(kernel, pars) … … 247 262 248 263 def is_near(target, actual, digits=5): 264 # type: (float, float, int) -> bool 249 265 """ 250 266 Returns true if *actual* is within *digits* significant digits of *target*. … … 255 271 256 272 def main(): 273 # type: () -> int 257 274 """ 258 275 Run tests given is sys.argv. … … 288 305 python -m sasmodels.model_test [-v] [opencl|dll] model1 model2 ... 289 306 290 If -v is included on the command line, then use verbo e output.307 If -v is included on the command line, then use verbose output. 291 308 292 309 If neither opencl nor dll is specified, then models will be tested with 293 both opencland dll; the compute target is ignored for pure python models.310 both OpenCL and dll; the compute target is ignored for pure python models. 294 311 295 312 If model1 is 'all', then all except the remaining models will be tested. … … 306 323 307 324 def model_tests(): 325 # type: () -> Iterator[Callable[[], None] 308 326 """ 309 327 Test runner visible to nosetests. -
sasmodels/modelinfo.py
r0d99a6a re62a134 640 640 info.variant_info = getattr(kernel_module, 'variant_info', None) 641 641 info.source = getattr(kernel_module, 'source', []) 642 # TODO: check the structure of the tests 642 643 info.tests = getattr(kernel_module, 'tests', []) 643 644 info.ER = getattr(kernel_module, 'ER', None) … … 712 713 source = None # type: List[str] 713 714 tests = None # type: List[TestCondition] 714 ER = None # type: Optional[Callable[[np.ndarray, ...], float]]715 VR = None # type: Optional[Callable[[np.ndarray, ...], float]]715 ER = None # type: Optional[Callable[[np.ndarray, ...], np.ndarray]] 716 VR = None # type: Optional[Callable[[np.ndarray, ...], Tuple[np.ndarray, np.ndarray]]] 716 717 form_volume = None # type: Optional[Callable[[np.ndarray, ...], float]] 717 718 Iq = None # type: Optional[Callable[[np.ndarray, ...], np.ndarray]]
Note: See TracChangeset
for help on using the changeset viewer.