Changeset 13ed84c in sasmodels for sasmodels/model_test.py
- Timestamp:
- Feb 4, 2016 7:31:28 PM (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:
- 199d40d
- Parents:
- 5054e80
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/model_test.py
r5c962df r13ed84c 100 100 test_name = "Model: %s, Kernel: OpenCL"%model_name 101 101 test_method_name = "test_%s_opencl" % model_name 102 # Using dtype=None so that the models that are only 103 # correct for double precision are not tested using 104 # single precision. The choice is determined by the 105 # presence of *single=False* in the model file. 102 106 test = ModelTestCase(test_name, model_definition, 103 107 test_method_name, 104 platform="ocl", dtype= 'single')108 platform="ocl", dtype=None) 105 109 #print("defining", test_name) 106 110 suite.addTest(test) … … 157 161 ## values an error. Only do so for the "dll" tests 158 162 ## to reduce noise from both opencl and dll, and because 159 ## python kernels us 163 ## python kernels use platform="dll". 160 164 #raise Exception("No test cases provided") 161 165 pass … … 198 202 'invalid f(%s): %s' % (xi, actual_yi)) 199 203 else: 200 err = abs(yi - actual_yi) 201 nrm = abs(yi) 202 self.assertLess(err * 10**5, nrm, 204 self.assertTrue(is_near(yi, actual_yi, 5), 203 205 'f(%s); expected:%s; actual:%s' 204 206 % (xi, yi, actual_yi)) … … 206 208 return ModelTestCase 207 209 208 210 def is_near(target, actual, digits=5): 211 """ 212 Returns true if *actual* is within *digits* significant digits of *target*. 213 """ 214 import math 215 shift = 10**math.ceil(math.log10(abs(target))) 216 return abs(target-actual)/shift < 1.5*10**-digits 209 217 210 218 def main(): … … 217 225 218 226 models = sys.argv[1:] 227 if models and models[0] == '-v': 228 verbosity = 2 229 models = models[1:] 230 else: 231 verbosity = 1 219 232 if models and models[0] == 'opencl': 220 233 if not HAVE_OPENCL: … … 235 248 print("""\ 236 249 usage: 237 python -m sasmodels.model_test [opencl|dll|opencl_and_dll] model1 model2 ... 250 python -m sasmodels.model_test [-v] [opencl|dll] model1 model2 ... 251 252 If -v is included on the 253 If neither opencl nor dll is specified, then models will be tested with 254 both opencl and dll; the compute target is ignored for pure python models. 238 255 239 256 If model1 is 'all', then all except the remaining models will be tested. 240 If no compute target is specified, then models will be tested with both opencl 241 and dll; the compute target is ignored for pure python models.""")257 258 """) 242 259 243 260 return 1 244 261 245 262 #runner = unittest.TextTestRunner() 246 runner = xmlrunner.XMLTestRunner(output='logs' )263 runner = xmlrunner.XMLTestRunner(output='logs', verbosity=verbosity) 247 264 result = runner.run(make_suite(loaders, models)) 248 265 return 1 if result.failures or result.errors else 0
Note: See TracChangeset
for help on using the changeset viewer.