Changeset 9a5097c in sasview for src/sas/sascalc/fit/BumpsFitting.py
- Timestamp:
- Mar 26, 2017 11:33:16 PM (8 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- ed2276f
- Parents:
- 9146ed9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/fit/BumpsFitting.py
r1a30720 r9a5097c 6 6 import traceback 7 7 8 import numpy 8 import numpy as np 9 9 10 10 from bumps import fitters … … 97 97 try: 98 98 p = history.population_values[0] 99 n,p = len(p), n umpy.sort(p)99 n,p = len(p), np.sort(p) 100 100 QI,Qmid, = int(0.2*n),int(0.5*n) 101 101 self.convergence.append((best, p[0],p[QI],p[Qmid],p[-1-QI],p[-1])) … … 194 194 195 195 def numpoints(self): 196 return n umpy.sum(self.data.idx) # number of fitted points196 return np.sum(self.data.idx) # number of fitted points 197 197 198 198 def nllf(self): 199 return 0.5*n umpy.sum(self.residuals()**2)199 return 0.5*np.sum(self.residuals()**2) 200 200 201 201 def theory(self): … … 295 295 if R.success: 296 296 if result['stderr'] is None: 297 R.stderr = n umpy.NaN*numpy.ones(len(param_list))297 R.stderr = np.NaN*np.ones(len(param_list)) 298 298 else: 299 R.stderr = n umpy.hstack((result['stderr'][fitted_index],300 numpy.NaN*numpy.ones(len(fitness.computed_pars))))301 R.pvec = n umpy.hstack((result['value'][fitted_index],299 R.stderr = np.hstack((result['stderr'][fitted_index], 300 np.NaN*np.ones(len(fitness.computed_pars)))) 301 R.pvec = np.hstack((result['value'][fitted_index], 302 302 [p.value for p in fitness.computed_pars])) 303 R.fitness = n umpy.sum(R.residuals**2)/(fitness.numpoints() - len(fitted_index))303 R.fitness = np.sum(R.residuals**2)/(fitness.numpoints() - len(fitted_index)) 304 304 else: 305 R.stderr = n umpy.NaN*numpy.ones(len(param_list))306 R.pvec = n umpy.asarray( [p.value for p in fitness.fitted_pars+fitness.computed_pars])307 R.fitness = n umpy.NaN305 R.stderr = np.NaN*np.ones(len(param_list)) 306 R.pvec = np.asarray( [p.value for p in fitness.fitted_pars+fitness.computed_pars]) 307 R.fitness = np.NaN 308 308 R.convergence = result['convergence'] 309 309 if result['uncertainty'] is not None: … … 336 336 max_step = steps + options.get('burn', 0) 337 337 pars = [p.name for p in problem._parameters] 338 #x0 = n umpy.asarray([p.value for p in problem._parameters])338 #x0 = np.asarray([p.value for p in problem._parameters]) 339 339 options['monitors'] = [ 340 340 BumpsMonitor(handler, max_step, pars, problem.dof), … … 351 351 errors = [] 352 352 except Exception as exc: 353 best, fbest = None, n umpy.NaN353 best, fbest = None, np.NaN 354 354 errors = [str(exc), traceback.format_exc()] 355 355 finally: … … 358 358 359 359 convergence_list = options['monitors'][-1].convergence 360 convergence = (2*n umpy.asarray(convergence_list)/problem.dof361 if convergence_list else n umpy.empty((0,1),'d'))360 convergence = (2*np.asarray(convergence_list)/problem.dof 361 if convergence_list else np.empty((0,1),'d')) 362 362 363 363 success = best is not None
Note: See TracChangeset
for help on using the changeset viewer.