Changeset 0763009 in sasmodels
- Timestamp:
- Oct 29, 2015 6:08:10 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:
- 381ac85
- Parents:
- 3d5c6f8
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
compare.py
r3e6aaad r0763009 100 100 model = sasview_model(name, **pars) 101 101 smearer = smear_selection(data, model=model) 102 value = None # silence the linter 102 103 toc = tic() 103 for _ in range( Nevals):104 for _ in range(max(Nevals, 1)): # make sure there is at least one eval 104 105 if hasattr(data, 'qx_data'): 105 106 q = np.sqrt(data.qx_data**2 + data.qy_data**2) … … 120 121 return value, average_time 121 122 122 def eval_opencl(model_definition, pars, data, dtype='single', Nevals=1, cutoff=0 ):123 def eval_opencl(model_definition, pars, data, dtype='single', Nevals=1, cutoff=0.): 123 124 try: 124 125 model = core.load_model(model_definition, dtype=dtype, platform="ocl") … … 128 129 model = core.load_model(model_definition, dtype='single', platform="ocl") 129 130 problem = Experiment(data, Model(model, **pars), cutoff=cutoff) 131 value = None # silence the linter 130 132 toc = tic() 131 for _ in range( Nevals):133 for _ in range(max(Nevals, 1)): # force at least one eval 132 134 #pars['scale'] = np.random.rand() 133 135 problem.update() … … 136 138 return value, average_time 137 139 138 def eval_ctypes(model_definition, pars, data, dtype='double', Nevals=1, cutoff=0 ):140 def eval_ctypes(model_definition, pars, data, dtype='double', Nevals=1, cutoff=0.): 139 141 model = core.load_model(model_definition, dtype=dtype, platform="dll") 140 142 problem = Experiment(data, Model(model, **pars), cutoff=cutoff) 143 value = None # silence the linter 141 144 toc = tic() 142 for _ in range( Nevals):145 for _ in range(max(Nevals, 1)): # force at least one eval 143 146 problem.update() 144 147 value = problem.theory() … … 224 227 #bad = (relerr>1e-4) 225 228 #print relerr[bad],cpu[bad],ocl[bad],data.qx_data[bad],data.qy_data[bad] 226 def stats(label,err): 227 sorted_err = np.sort(abs(err)) 228 p50 = int((len(err)-1)*0.50) 229 p98 = int((len(err)-1)*0.98) 230 data = [ 231 "max:%.3e"%sorted_err[-1], 232 "median:%.3e"%sorted_err[p50], 233 "98%%:%.3e"%sorted_err[p98], 234 "rms:%.3e"%np.sqrt(np.mean(err**2)), 235 "zero-offset:%+.3e"%np.mean(err), 236 ] 237 print label," ".join(data) 238 stats("|ocl-%s|"%comp+(" "*(3+len(comp))), resid) 239 stats("|(ocl-%s)/%s|"%(comp,comp), relerr) 229 _print_stats("|ocl-%s|"%comp+(" "*(3+len(comp))), resid) 230 _print_stats("|(ocl-%s)/%s|"%(comp,comp), relerr) 240 231 241 232 # Plot if requested … … 277 268 plt.show() 278 269 270 def _print_stats(label, err): 271 sorted_err = np.sort(abs(err)) 272 p50 = int((len(err)-1)*0.50) 273 p98 = int((len(err)-1)*0.98) 274 data = [ 275 "max:%.3e"%sorted_err[-1], 276 "median:%.3e"%sorted_err[p50], 277 "98%%:%.3e"%sorted_err[p98], 278 "rms:%.3e"%np.sqrt(np.mean(err**2)), 279 "zero-offset:%+.3e"%np.mean(err), 280 ] 281 print label," ".join(data) 282 283 284 279 285 # =========================================================================== 280 286 # -
sasmodels/exception.py
r9e430d0 r0763009 2 2 Utility to add annotations to python exceptions. 3 3 """ 4 5 # Platform cruft: WindowsError is only defined on Windows. 6 try: 7 WindowsError 8 except NameError: 9 class WindowsError(Exception): 10 pass 4 11 5 12 def annotate_exception(exc, msg): … … 19 26 KeyError: "hello while accessing 'D'" 20 27 """ 28 # Can't extend WindowsError exceptions; instead raise a new exception. 29 # TODO: try to incorporate current stack trace in the raised exception 30 if isinstance(exc, WindowsError): 31 raise OSError(str(exc)+msg) 32 21 33 args = exc.args 22 34 if not args: … … 28 40 except: 29 41 exc.args = (" ".join((str(exc),msg)),) 30 -
sasmodels/kernelcl.py
raf1d68c r0763009 39 39 40 40 from . import generate 41 from .kernelpy import PyModel42 41 43 42 F64_DEFS = """\ -
sasmodels/kerneldll.py
rf3f46cd r0763009 148 148 try: 149 149 self.dll = ct.CDLL(self.dllpath) 150 except WindowsError, exc:151 # TODO: update annotate_exception so it can handle WindowsError152 raise RuntimeError(str(exc)+" while loading "+self.dllpath)153 150 except Exception, exc: 154 151 annotate_exception(exc, "while loading "+self.dllpath)
Note: See TracChangeset
for help on using the changeset viewer.