Changeset 4bfd277 in sasmodels for sasmodels/model_test.py
- Timestamp:
- Apr 8, 2016 10:11:16 AM (8 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:
- 2afc26d
- Parents:
- d2fc9a4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/model_test.py
r6d6508e r4bfd277 56 56 from .direct_model import call_kernel, get_weights 57 57 from .exception import annotate_exception 58 59 60 def call_ER(model_info, values):58 from .modelinfo import expand_pars 59 60 def call_ER(model_info, pars): 61 61 """ 62 62 Call the model ER function using *values*. *model_info* is either … … 67 67 return 1.0 68 68 else: 69 vol_pars = [get_weights(parameter, values) 70 for parameter in model_info.parameters.call_parameters 71 if parameter.type == 'volume'] 72 value, weight = dispersion_mesh(vol_pars) 69 value, weight = _vol_pars(model_info, pars) 73 70 individual_radii = model_info.ER(*value) 74 71 return np.sum(weight*individual_radii) / np.sum(weight) 75 72 76 def call_VR(model_info, values):73 def call_VR(model_info, pars): 77 74 """ 78 75 Call the model VR function using *pars*. … … 83 80 return 1.0 84 81 else: 85 vol_pars = [get_weights(parameter, values) 86 for parameter in model_info.parameters.call_parameters 87 if parameter.type == 'volume'] 88 value, weight = dispersion_mesh(vol_pars) 82 value, weight = _vol_pars(model_info, pars) 89 83 whole, part = model_info.VR(*value) 90 84 return np.sum(weight*part)/np.sum(weight*whole) 85 86 def _vol_pars(model_info, pars): 87 vol_pars = [get_weights(p, pars) 88 for p in model_info.parameters.call_parameters 89 if p.type == 'volume'] 90 value, weight = dispersion_mesh(model_info, vol_pars) 91 return value, weight 91 92 92 93 … … 175 176 self.dtype = dtype 176 177 177 setattr(self, test_method_name, self. _runTest)178 setattr(self, test_method_name, self.run_all) 178 179 unittest.TestCase.__init__(self, test_method_name) 179 180 180 def _runTest(self):181 def run_all(self): 181 182 smoke_tests = [ 182 183 [{}, 0.1, None], … … 191 192 platform=self.platform) 192 193 for test in smoke_tests + tests: 193 self. _run_one_test(model, test)194 self.run_one(model, test) 194 195 195 196 if not tests and self.platform == "dll": … … 205 206 raise 206 207 207 def _run_one_test(self, model, test):208 def run_one(self, model, test): 208 209 pars, x, y = test 210 pars = expand_pars(self.info.parameters, pars) 209 211 210 212 if not isinstance(y, list): … … 229 231 actual = call_kernel(kernel, pars) 230 232 231 self.assert Greater(len(actual),0)233 self.assertTrue(len(actual) > 0) 232 234 self.assertEqual(len(y), len(actual)) 233 235 … … 311 313 tests = make_suite(['opencl', 'dll'], ['all']) 312 314 for test_i in tests: 313 yield test_i. _runTest315 yield test_i.run_all 314 316 315 317
Note: See TracChangeset
for help on using the changeset viewer.