Changeset 503527e in sasmodels
- Timestamp:
- Nov 9, 2015 4:35:43 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:
- bea48a6
- Parents:
- cbb54e2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/model_test.py
r9e430d0 r503527e 68 68 model_definition = load_model_definition(model_name) 69 69 70 smoke_tests = [71 [{},0.1,None],72 [{},(0.1,0.1),None],73 [{},'ER',None], 74 [{},'VR',None],75 ]76 tests = smoke_tests + getattr(model_definition, 'tests', [])77 78 if tests: # in case there are no smoke tests... 79 #print '------'80 #print 'found tests in',model_name81 #print '------'82 83 # if ispy then use the dll loader to call pykernel84 # don't try to call cl kernel since it will not be85 # available in some environmentes.86 ispy = callable(getattr(model_definition,'Iq', None))87 88 # test using opencl if desired 89 if not ispy and ('opencl' in loaders and HAVE_OPENCL):70 #print '------' 71 #print 'found tests in', model_name 72 #print '------' 73 74 # if ispy then use the dll loader to call pykernel 75 # don't try to call cl kernel since it will not be 76 # available in some environmentes. 77 is_py = callable(getattr(model_definition,'Iq', None)) 78 79 if is_py: # kernel implemented in python 80 test_name = "Model: %s, Kernel: python"%model_name 81 test_method_name = "test_%s_python" % model_name 82 test = ModelTestCase(test_name, model_definition, 83 test_method_name, 84 platform="dll", # so that 85 dtype="double") 86 suite.addTest(test) 87 else: # kernel implemented in C 88 # test using opencl if desired and available 89 if 'opencl' in loaders and HAVE_OPENCL: 90 90 test_name = "Model: %s, Kernel: OpenCL"%model_name 91 test_method = "test_%s_opencl" % model_name91 test_method_name = "test_%s_opencl" % model_name 92 92 test = ModelTestCase(test_name, model_definition, 93 test s, test_method,93 test_method_name, 94 94 platform="ocl", dtype='single') 95 95 #print "defining", test_name … … 97 97 98 98 # test using dll if desired 99 if ispy or'dll' in loaders:99 if 'dll' in loaders: 100 100 test_name = "Model: %s, Kernel: dll"%model_name 101 test_method = "test_%s_dll" % model_name101 test_method_name = "test_%s_dll" % model_name 102 102 test = ModelTestCase(test_name, model_definition, 103 tests, test_method, 104 platform="dll", dtype="double") 103 test_method_name, 104 platform="dll", 105 dtype="double") 105 106 suite.addTest(test) 106 107 … … 110 111 def _hide_model_case_from_nosetests(): 111 112 class ModelTestCase(unittest.TestCase): 112 def __init__(self, test_name, definition, test s, test_method,113 def __init__(self, test_name, definition, test_method_name, 113 114 platform, dtype): 114 115 self.test_name = test_name 115 116 self.definition = definition 116 self.tests = tests117 117 self.platform = platform 118 118 self.dtype = dtype 119 119 120 setattr(self, test_method , self._runTest)121 unittest.TestCase.__init__(self, test_method )120 setattr(self, test_method_name, self._runTest) 121 unittest.TestCase.__init__(self, test_method_name) 122 122 123 123 def _runTest(self): 124 smoke_tests = [ 125 [{},0.1,None], 126 [{},(0.1,0.1),None], 127 [{},'ER',None], 128 [{},'VR',None], 129 ] 130 131 tests = getattr(self.definition, 'tests', []) 124 132 try: 125 133 model = load_model(self.definition, dtype=self.dtype, 126 134 platform=self.platform) 127 for test in s elf.tests:135 for test in smoke_tests + tests: 128 136 self._run_one_test(model, test) 137 138 if not tests and self.platform == "dll": 139 ## Uncomment the following to make forgetting the test 140 ## values an error. Only do so for the "dll" tests 141 ## to reduce noise from both opencl and dll, and because 142 ## python kernels us 143 raise Exception("No test cases provided") 144 pass 129 145 130 146 except Exception,exc: … … 199 215 loaders = ['opencl', 'dll'] 200 216 if not models: 201 print >>sys.stderr, "usage: python -m sasmodels.model_test [opencl|dll|opencl_and_dll] model1 model2 ..." 202 print >>sys.stderr, "if model1 is 'all', then all except the remaining models will be tested" 217 print >>sys.stderr, """\ 218 usage: 219 python -m sasmodels.model_test [opencl|dll|opencl_and_dll] model1 model2 ... 220 221 If model1 is 'all', then all except the remaining models will be tested. 222 If no compute target is specified, then models will be tested with both opencl 223 and dll; the compute target is ignored for pure python models.""" 224 203 225 return 1 204 226
Note: See TracChangeset
for help on using the changeset viewer.