Changeset 792
- Timestamp:
- 06/10/15 13:01:55 (11 months ago)
- Location:
- mystic
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
mystic/_math/compressed.py
r776 r792 49 49 """convert a list of binary strings to product measure coordinates""" 50 50 reduce = True # 'reduce' len=1 and len=0 results 51 if kwds.has_key('reduce'): reduce = kwds['reduce']51 if 'reduce' in kwds: reduce = kwds['reduce'] 52 52 result = [tuple([j[0][j[1]] for j in \ 53 53 zip(positions,[int(i) for i in vk])]) for vk in binaries] -
mystic/_math/distance.py
r776 r792 54 54 """ 55 55 # dmin: force upconvert to x,x' to dimension >= dmin 56 dmin = 0 # default 57 if kwds.has_key('dmin'): 58 dmin = kwds['dmin'] 56 dmin = kwds['dmin'] if 'dmin' in kwds else 0 # default dimension 59 57 from numpy import abs, asarray, newaxis as nwxs 60 58 from __builtin__ import max … … 270 268 tol = kwds.pop('tol', 0.0) 271 269 cutoff = tol # default is to zero out distances less than tolerance 272 if kwds.has_key('cutoff'): cutoff = kwds.pop('cutoff')270 if 'cutoff' in kwds: cutoff = kwds.pop('cutoff') 273 271 if cutoff is True: cutoff = tol 274 272 elif cutoff is False: cutoff = None … … 329 327 # thus, we 'pass' on using constraints at this time... 330 328 constraints = None # default is no constraints 331 if kwds.has_key('constraints'): constraints = kwds.pop('constraints')329 if 'constraints' in kwds: constraints = kwds.pop('constraints') 332 330 if not constraints: # if None (default), there are no constraints 333 331 constraints = lambda x: x … … 338 336 339 337 cutoff = ytol # default is to zero out distances less than tolerance 340 if kwds.has_key('cutoff'): cutoff = kwds.pop('cutoff')338 if 'cutoff' in kwds: cutoff = kwds.pop('cutoff') 341 339 if cutoff is True: cutoff = ytol 342 340 elif cutoff is False: cutoff = None -
mystic/_math/legacydata.py
r776 r792 325 325 of any element less than the cutoff. 326 326 """ 327 tol = kwds .get('tol', 0.0)# get tolerance in y327 tol = kwds['tol'] if 'tol' in kwds else 0.0 # get tolerance in y 328 328 # default is to zero out distances less than tolerance 329 cutoff = kwds .get('cutoff', tol)329 cutoff = kwds['cutoff'] if 'cutoff' in kwds else tol 330 330 if cutoff is True: cutoff = tol 331 331 elif cutoff is False: cutoff = None … … 375 375 values are normalized by norm = hausdorff. 376 376 """ 377 ytol = kwds .get('ytol', 0.0)# get tolerance in y377 ytol = kwds['ytol'] if 'ytol' in kwds else 0.0 # get tolerance in y 378 378 # default is to zero out distances less than tolerance 379 cutoff = kwds .get('cutoff', ytol)379 cutoff = kwds['cutoff'] if 'cutoff' in kwds else ytol 380 380 if cutoff is True: cutoff = ytol 381 381 elif cutoff is False: cutoff = None -
mystic/_math/measures.py
r791 r792 303 303 # plug in the 'constraints' function: samples' = constrain(samples, weights) 304 304 constrain = None # default is no constraints 305 if kwds.has_key('constraints'): constrain = kwds['constraints']305 if 'constraints' in kwds: constrain = kwds['constraints'] 306 306 if not constrain: # if None (default), there are no constraints 307 307 constraints = lambda x: x … … 333 333 334 334 # construct and configure optimizer 335 debug = False 336 if kwds.has_key('debug'): debug = kwds['debug'] 335 debug = kwds['debug'] if 'debug' in kwds else False 337 336 npop = 200 338 337 maxiter = 1000; maxfun = 1e+6 -
mystic/models/abstract_model.py
r776 r792 71 71 72 72 def __call__(self,*args,**kwds): 73 coeffs = kwds .get('coeffs',args[0] if len(args) else [])73 coeffs = kwds['coeffs'] if 'coeffs' in kwds else (args[0] if len(args) else []) 74 74 if len(coeffs) != self.ndim: 75 75 raise ValueError('input length does not match ndim (ndim=%d)' % self.ndim) -
mystic/mystic/_genSow.py
r776 r792 36 36 corresponding properties as required inputs for the Monitor. 37 37 """ 38 self.__args = [ i for i in args if self.__dict.has_key(i)]38 self.__args = [ i for i in args if i in self.__dict ] 39 39 exec(self._genClass()) # generates Monitor() 40 40 return Monitor() -
mystic/mystic/_symbolic.py
r776 r792 271 271 verbose = False # if True, print debug info 272 272 #-----------------------undocumented------------------------------- 273 if kwds.has_key('permute'): permute = kwds['permute']274 if kwds.has_key('warn'): warn = kwds['warn']275 if kwds.has_key('verbose'): verbose = kwds['verbose']273 permute = kwds['permute'] if 'permute' in kwds else permute 274 warn = kwds['warn'] if 'warn' in kwds else warn 275 verbose = kwds['verbose'] if 'verbose' in kwds else verbose 276 276 #------------------------------------------------------------------ 277 277 if target in [None, False]: … … 310 310 # default is _locals with sympy imported 311 311 _locals = {} 312 locals = kwds .get('locals', None)312 locals = kwds['locals'] if 'locals' in kwds else None 313 313 if locals is None: locals = {} 314 314 try: … … 439 439 verbose = False # if True, print debug info 440 440 #-----------------------undocumented------------------------------- 441 if kwds.has_key('permute'): permute = kwds['permute']442 if kwds.has_key('warn'): warn = kwds['warn']443 if kwds.has_key('verbose'): verbose = kwds['verbose']441 permute = kwds['permute'] if 'permute' in kwds else permute 442 warn = kwds['warn'] if 'warn' in kwds else warn 443 verbose = kwds['verbose'] if 'verbose' in kwds else verbose 444 444 #------------------------------------------------------------------ 445 445 if target in [None, False]: … … 478 478 # default is _locals with sympy imported 479 479 _locals = {} 480 locals = kwds .get('locals', None)480 locals = kwds['locals'] if 'locals' in kwds else None 481 481 if locals is None: locals = {} 482 482 # if sympy not installed, return original constraints … … 699 699 verbose = False # if True, print details from _classify_variables 700 700 #-----------------------undocumented------------------------------- 701 if kwds.has_key('permute'): permute = kwds['permute']702 if kwds.has_key('warn'): warn = kwds['warn']703 if kwds.has_key('verbose'): verbose = kwds['verbose']701 permute = kwds['permute'] if 'permute' in kwds else permute 702 warn = kwds['warn'] if 'warn' in kwds else warn 703 verbose = kwds['verbose'] if 'verbose' in kwds else verbose 704 704 #------------------------------------------------------------------ 705 705 if target in [None, False]: … … 732 732 return mystring 733 733 734 locals = kwds .get('locals', None)734 locals = kwds['locals'] if 'locals' in kwds else None 735 735 if locals is None: locals = {} 736 736 -
mystic/mystic/abstract_ensemble_solver.py
r785 r792 116 116 117 117 # default settings for nested optimization 118 nbins = [1]*dim 119 if kwds.has_key('nbins'): nbins = kwds['nbins'] 118 nbins = kwds['nbins'] if 'nbins' in kwds else [1]*dim 120 119 if isinstance(nbins, int): 121 120 from mystic.math.grid import randomly_bin 122 121 nbins = randomly_bin(nbins, dim, ones=True, exact=True) 123 122 self._nbins = nbins 124 npts = 1 125 if kwds.has_key('npts'): npts = kwds['npts'] 123 npts = kwds['npts'] if 'npts' in kwds else 1 126 124 self._npts = npts 127 125 from mystic.solvers import NelderMeadSimplexSolver … … 129 127 self._bestSolver = None # 'best' solver (after Solve) 130 128 self._total_evals = 0 # total function calls (after Solve) 131 if kwds.has_key('nbins'): NP = reduce(lambda x,y:x*y, nbins) 132 else: NP = npts #XXX: merge npts/nbins kwds? 129 NP = reduce(lambda x,y:x*y, nbins) if 'nbins' in kwds else npts 133 130 self._allSolvers = [None for j in range(NP)] 134 131 return -
mystic/mystic/abstract_launcher.py
r776 r792 120 120 except KeyError: 121 121 nodes = args[0] 122 else: nodes = kwds .get('nodes', self.__nodes)122 else: nodes = kwds['nodes'] if 'nodes' in kwds else self.__nodes 123 123 try: self.nodes = nodes 124 124 except TypeError: pass # then self.nodes is read-only -
mystic/mystic/abstract_solver.py
r791 r792 110 110 signal_handler - catches the interrupt signal. 111 111 """ 112 NP = 1113 if kwds.has_key('npop'): NP = kwds['npop']112 NP = kwds['npop'] if 'npop' in kwds else 1 113 #self._max = kwds['max'] if 'max' in kwds else False 114 114 115 115 self.nDim = dim … … 150 150 self._cost = (None, None, None) 151 151 # (cost, raw_cost, args) #,callback) 152 self._termination = lambda x, *ar, **kw: False if len(ar) < 1 or ar[0] is False or kw.get('info',True) == False else '' #XXX: better default ?152 self._termination = lambda x, *ar, **kw: False if len(ar) < 1 or ar[0] is False or (kw['info'] if 'info' in kw else True) == False else '' #XXX: better default ? 153 153 # (get termination details with self._termination.__doc__) 154 154 … … 170 170 171 171 def __energy_history(self): 172 """get the energy_history (default: energy_history = _stepmon. y)"""173 if self._energy_history is None: return self._stepmon. y172 """get the energy_history (default: energy_history = _stepmon._y)""" 173 if self._energy_history is None: return self._stepmon._y 174 174 return self._energy_history 175 175 176 176 def __set_energy_history(self, energy): 177 """set the energy_history (energy=None will sync with _stepmon. y)"""177 """set the energy_history (energy=None will sync with _stepmon._y)""" 178 178 self._energy_history = energy 179 179 return … … 280 280 else: 281 281 raise TypeError, "'%s' is not a monitor instance" % monitor 282 self.energy_history = self._stepmon.y283 self.solution_history = self._stepmon.x282 self.energy_history = None # sync with self._stepmon 283 self.solution_history = None # sync with self._stepmon 284 284 return 285 285 … … 506 506 - generations = maximum number of solver iterations (i.e. steps) 507 507 - evaluations = maximum number of function evaluations""" 508 self._maxiter = generations509 self._maxfun = evaluations510 508 # backward compatibility 511 if kwds.has_key('maxiter'): 512 self._maxiter = kwds['maxiter'] 513 if kwds.has_key('maxfun'): 514 self._maxfun = kwds['maxfun'] 509 self._maxiter = kwds['maxiter'] if 'maxiter' in kwds else generations 510 self._maxfun = kwds['maxfun'] if 'maxfun' in kwds else evaluations 515 511 # handle if new (reset counter, instead of extend counter) 516 512 if new: … … 699 695 [settings.update({i:j}) for (i,j) in kwds.items() if i in settings] 700 696 # backward compatibility 701 if kwds.has_key('EvaluationMonitor'): \702 self.SetEvaluationMonitor(kwds .get('EvaluationMonitor'))703 if kwds.has_key('StepMonitor'): \704 self.SetGenerationMonitor(kwds .get('StepMonitor'))705 if kwds.has_key('penalty'): \706 self.SetPenalty(kwds .get('penalty'))707 if kwds.has_key('constraints'): \708 self.SetConstraints(kwds .get('constraints'))697 if 'EvaluationMonitor' in kwds: \ 698 self.SetEvaluationMonitor(kwds['EvaluationMonitor']) 699 if 'StepMonitor' in kwds: \ 700 self.SetGenerationMonitor(kwds['StepMonitor']) 701 if 'penalty' in kwds: \ 702 self.SetPenalty(kwds['penalty']) 703 if 'constraints' in kwds: \ 704 self.SetConstraints(kwds['constraints']) 709 705 return settings 710 706 -
mystic/mystic/differential_evolution.py
r791 r792 293 293 scale=self.scale #multiplier for mutation impact 294 294 [settings.update({i:j}) for (i,j) in kwds.items() if i in settings] 295 self.probability = kwds.get('CrossProbability', probability) 296 self.scale = kwds.get('ScalingFactor', scale) 295 word = 'CrossProbability' 296 self.probability = kwds[word] if word in kwds else probability 297 word = 'ScalingFactor' 298 self.scale = kwds[word] if word in kwds else scale 297 299 self.strategy = getattr(settings['strategy'],'__name__','Best1Bin') 298 300 return settings … … 471 473 scale=self.scale #multiplier for mutation impact 472 474 [settings.update({i:j}) for (i,j) in kwds.items() if i in settings] 473 self.probability = kwds.get('CrossProbability', probability) 474 self.scale = kwds.get('ScalingFactor', scale) 475 word = 'CrossProbability' 476 self.probability = kwds[word] if word in kwds else probability 477 word = 'ScalingFactor' 478 self.scale = kwds[word] if word in kwds else scale 475 479 self.strategy = getattr(settings['strategy'],'__name__','Best1Bin') 476 480 return settings … … 573 577 574 578 """ 575 invariant_current = True 576 if kwds.has_key('invariant_current'): 577 invariant_current = kwds['invariant_current'] 579 invariant_current = kwds['invariant_current'] if 'invariant_current' in kwds else True 578 580 kwds['invariant_current'] = invariant_current 579 581 return diffev(cost,x0,npop,args=args,bounds=bounds,ftol=ftol,gtol=gtol, … … 643 645 644 646 """ 645 invariant_current = False 646 if kwds.has_key('invariant_current'): 647 invariant_current = kwds['invariant_current'] 648 handler = False 649 if kwds.has_key('handler'): 650 handler = kwds['handler'] 647 invariant_current = kwds['invariant_current'] if 'invariant_current' in kwds else False 648 handler = kwds['handler'] if 'handler' in kwds else False 651 649 652 650 from mystic.strategy import Best1Bin 653 strategy = Best1Bin 654 if kwds.has_key('strategy'): 655 strategy = kwds['strategy'] 651 strategy = kwds['strategy'] if 'strategy' in kwds else Best1Bin 656 652 from mystic.monitors import Monitor 657 stepmon = Monitor() 658 evalmon = Monitor() 659 if kwds.has_key('itermon'): 660 stepmon = kwds['itermon'] 661 if kwds.has_key('evalmon'): 662 evalmon = kwds['evalmon'] 653 stepmon = kwds['itermon'] if 'itermon' in kwds else Monitor() 654 evalmon = kwds['evalmon'] if 'evalmon' in kwds else Monitor() 655 663 656 if gtol: #if number of generations provided, use ChangeOverGeneration 664 657 from mystic.termination import ChangeOverGeneration … … 676 669 solver.SetEvaluationMonitor(evalmon) 677 670 solver.SetGenerationMonitor(stepmon) 678 if kwds.has_key('penalty'): 679 penalty = kwds['penalty'] 680 solver.SetPenalty(penalty) 681 if kwds.has_key('constraints'): 682 constraints = kwds['constraints'] 683 solver.SetConstraints(constraints) 671 if 'penalty' in kwds: 672 solver.SetPenalty(kwds['penalty']) 673 if 'constraints' in kwds: 674 solver.SetConstraints(kwds['constraints']) 684 675 if bounds is not None: 685 676 minb,maxb = unpair(bounds) -
mystic/mystic/ensemble.py
r791 r792 85 85 sigint_callback = kwds.pop('sigint_callback', None) 86 86 settings = self._process_inputs(kwds) 87 disp = settings .get('disp', False)88 echo = settings .get('callback', None) #XXX: every iteration every run87 disp = settings['disp'] if 'disp' in settings else False 88 echo = settings['callback'] if 'callback' in settings else None 89 89 # for key in settings: 90 90 # exec "%s = settings['%s']" % (key,key) … … 279 279 sigint_callback = kwds.pop('sigint_callback', None) 280 280 settings = self._process_inputs(kwds) 281 disp = settings .get('disp', False)282 echo = settings .get('callback', None) #XXX: every iteration every run281 disp = settings['disp'] if 'disp' in settings else False 282 echo = settings['callback'] if 'callback' in settings else None 283 283 # for key in settings: 284 284 # exec "%s = settings['%s']" % (key,key) … … 479 479 480 480 """ 481 handler = False 482 if kwds.has_key('handler'): 483 handler = kwds['handler'] 481 handler = kwds['handler'] if 'handler' in kwds else False 484 482 from mystic.solvers import NelderMeadSimplexSolver as _solver 485 if kwds.has_key('solver'): 486 _solver = kwds['solver'] 483 if 'solver' in kwds: _solver = kwds['solver'] 487 484 488 485 from mystic.monitors import Monitor 489 stepmon = Monitor() 490 evalmon = Monitor() 491 if kwds.has_key('itermon'): 492 stepmon = kwds['itermon'] 493 if kwds.has_key('evalmon'): 494 evalmon = kwds['evalmon'] 486 stepmon = kwds['itermon'] if 'itermon' in kwds else Monitor() 487 evalmon = kwds['evalmon'] if 'evalmon' in kwds else Monitor() 495 488 496 489 gtol = 10 # termination generations (scipy: 2, default: 10) 497 if kwds.has_key('gtol'): 498 gtol = kwds['gtol'] 490 if 'gtol' in kwds: gtol = kwds['gtol'] 499 491 if gtol: #if number of generations is provided, use NCOG 500 492 from mystic.termination import NormalizedChangeOverGeneration … … 509 501 solver.SetEvaluationMonitor(evalmon) 510 502 solver.SetGenerationMonitor(stepmon) 511 if kwds.has_key('penalty'): 512 penalty = kwds['penalty'] 513 solver.SetPenalty(penalty) 514 if kwds.has_key('constraints'): 515 constraints = kwds['constraints'] 516 solver.SetConstraints(constraints) 503 if 'penalty' in kwds: 504 solver.SetPenalty(kwds['penalty']) 505 if 'constraints' in kwds: 506 solver.SetConstraints(kwds['constraints']) 517 507 if bounds is not None: 518 508 minb,maxb = unpair(bounds) … … 610 600 611 601 """ 612 handler = False 613 if kwds.has_key('handler'): 614 handler = kwds['handler'] 602 handler = kwds['handler'] if 'handler' in kwds else False 615 603 from mystic.solvers import NelderMeadSimplexSolver as _solver 616 if kwds.has_key('solver'): 617 _solver = kwds['solver'] 604 if 'solver' in kwds: _solver = kwds['solver'] 618 605 619 606 from mystic.monitors import Monitor 620 stepmon = Monitor() 621 evalmon = Monitor() 622 if kwds.has_key('itermon'): 623 stepmon = kwds['itermon'] 624 if kwds.has_key('evalmon'): 625 evalmon = kwds['evalmon'] 607 stepmon = kwds['itermon'] if 'itermon' in kwds else Monitor() 608 evalmon = kwds['evalmon'] if 'evalmon' in kwds else Monitor() 626 609 627 610 gtol = 10 # termination generations (scipy: 2, default: 10) 628 if kwds.has_key('gtol'): 629 gtol = kwds['gtol'] 611 if 'gtol' in kwds: gtol = kwds['gtol'] 630 612 if gtol: #if number of generations is provided, use NCOG 631 613 from mystic.termination import NormalizedChangeOverGeneration … … 640 622 solver.SetEvaluationMonitor(evalmon) 641 623 solver.SetGenerationMonitor(stepmon) 642 if kwds.has_key('penalty'): 643 penalty = kwds['penalty'] 644 solver.SetPenalty(penalty) 645 if kwds.has_key('constraints'): 646 constraints = kwds['constraints'] 647 solver.SetConstraints(constraints) 624 if 'penalty' in kwds: 625 solver.SetPenalty(kwds['penalty']) 626 if 'constraints' in kwds: 627 solver.SetConstraints(kwds['constraints']) 648 628 if bounds is not None: 649 629 minb,maxb = unpair(bounds) -
mystic/mystic/munge.py
r791 r792 114 114 steps, energy = read_monitor(mon) 115 115 f = open(log_file,'w') 116 if kwds.has_key('header'): 117 header = kwds.pop('header') 118 f.write('# %s\n' % header) 116 if 'header' in kwds: 117 f.write('# %s\n' % kwds.pop('header')) 119 118 for variable,value in kwds.items(): # write remaining kwds as variables 120 119 f.write('%s = %s\n' % (variable,value)) … … 129 128 monitor = write_monitor( *raw_to_support( *read_monitor(mon) ) ) 130 129 header = "written in 'support' format" 131 if kwds.has_key('header'):130 if 'header' in kwds: 132 131 header += "\n# " + str(kwds.pop('header')) 133 132 write_raw_file(monitor,log_file,header=header,**kwds) … … 138 137 monitor = write_monitor( *raw_to_converge( *read_monitor(mon) ) ) 139 138 header = "written in 'converge' format" 140 if kwds.has_key('header'):139 if 'header' in kwds: 141 140 header += "\n# " + str(kwds.pop('header')) 142 141 write_raw_file(monitor,log_file,header=header,**kwds) -
mystic/mystic/scipy_optimize.py
r791 r792 363 363 364 364 """ 365 handler = False 366 if kwds.has_key('handler'): 367 handler = kwds['handler'] 365 handler = kwds['handler'] if 'handler' in kwds else False 368 366 369 367 from mystic.monitors import Monitor 370 stepmon = Monitor() 371 evalmon = Monitor() 372 if kwds.has_key('itermon'): 373 stepmon = kwds['itermon'] 374 if kwds.has_key('evalmon'): 375 evalmon = kwds['evalmon'] 368 stepmon = kwds['itermon'] if 'itermon' in kwds else Monitor() 369 evalmon = kwds['evalmon'] if 'evalmon' in kwds else Monitor() 376 370 377 371 if xtol: #if tolerance in x is provided, use CandidateRelativeTolerance … … 386 380 solver.SetEvaluationMonitor(evalmon) 387 381 solver.SetGenerationMonitor(stepmon) 388 if kwds.has_key('penalty'): 389 penalty = kwds['penalty'] 390 solver.SetPenalty(penalty) 391 if kwds.has_key('constraints'): 392 constraints = kwds['constraints'] 393 solver.SetConstraints(constraints) 382 if 'penalty' in kwds: 383 solver.SetPenalty(kwds['penalty']) 384 if 'constraints' in kwds: 385 solver.SetConstraints(kwds['constraints']) 394 386 if bounds is not None: 395 387 minb,maxb = unpair(bounds) … … 602 594 direc=self._direc #initial direction set 603 595 [settings.update({i:j}) for (i,j) in kwds.items() if i in settings] 604 self._direc = kwds .get('direc', direc)596 self._direc = kwds['direc'] if 'direc' in kwds else direc 605 597 self.xtol = settings['xtol'] 606 598 return settings … … 706 698 # - should just pass 'direc', and then hands-off ? How return it ? 707 699 708 handler = False 709 if kwds.has_key('handler'): 710 handler = kwds['handler'] 700 handler = kwds['handler'] if 'handler' in kwds else False 711 701 712 702 from mystic.monitors import Monitor 713 stepmon = Monitor() 714 evalmon = Monitor() 715 if kwds.has_key('itermon'): 716 stepmon = kwds['itermon'] 717 if kwds.has_key('evalmon'): 718 evalmon = kwds['evalmon'] 703 stepmon = kwds['itermon'] if 'itermon' in kwds else Monitor() 704 evalmon = kwds['evalmon'] if 'evalmon' in kwds else Monitor() 719 705 720 706 gtol = 2 # termination generations (scipy: 2, default: 10) 721 if kwds.has_key('gtol'): 722 gtol = kwds['gtol'] 707 if 'gtol' in kwds: gtol = kwds['gtol'] 723 708 if gtol: #if number of generations is provided, use NCOG 724 709 from mystic.termination import NormalizedChangeOverGeneration as NCOG … … 733 718 solver.SetEvaluationMonitor(evalmon) 734 719 solver.SetGenerationMonitor(stepmon) 735 if kwds.has_key('penalty'): 736 penalty = kwds['penalty'] 737 solver.SetPenalty(penalty) 738 if kwds.has_key('constraints'): 739 constraints = kwds['constraints'] 740 solver.SetConstraints(constraints) 720 if 'penalty' in kwds: 721 solver.SetPenalty(kwds['penalty']) 722 if 'constraints' in kwds: 723 solver.SetConstraints(kwds['constraints']) 741 724 if bounds is not None: 742 725 minb,maxb = unpair(bounds) -
mystic/mystic/solvers.py
r776 r792 80 80 def LoadSolver(filename=None, **kwds): 81 81 """load solver state from a restart file""" 82 if filename is None: filename = kwds.get('_state', None) 82 if filename is None: 83 filename = kwds['_state'] if '_state' in kwds else None 83 84 #XXX: only allow a list override keys (lookup values from self) 84 85 # if filename is None: filename = self._state -
mystic/scripts/mystic_log_reader.py
r776 r792 98 98 99 99 # parse file contents to get (i,id), cost, and parameters 100 from mystic.munge import logfile_reader 101 step, param, cost = logfile_reader(filename) 100 from mystic.munge import logfile_reader, read_raw_file 101 try: 102 step, param, cost = logfile_reader(filename) 103 except SyntaxError: 104 read_raw_file(filename) 105 msg = "incompatible file format, try 'support_convergence.py'" 106 raise SyntaxError(msg) 102 107 103 108 # ignore everything after 'stop' -
mystic/tests/test_solver_compare.py
r776 r792 24 24 exec "s1 = solvers.%s" % solver1 25 25 exec "s2 = solvers.%s" % solver2 26 maxiter = kwds .get('maxiter', None)27 maxfun = kwds .get('maxfun', None)26 maxiter = kwds['maxiter'] if 'maxiter' in kwds else None 27 maxfun = kwds['maxfun'] if 'maxfun' in kwds else None 28 28 s1_x = s1(rosen, x0, disp=0, full_output=True, **kwds) 29 29 s2_x = s2(rosen, x0, disp=0, full_output=True, **kwds) … … 48 48 exec "my = solvers.%s" % solvername 49 49 exec "sp = %s" % solvername 50 maxiter = kwds .get('maxiter', None)51 maxfun = kwds .get('maxfun', None)50 maxiter = kwds['maxiter'] if 'maxiter' in kwds else None 51 maxfun = kwds['maxfun'] if 'maxfun' in kwds else None 52 52 my_x = my(rosen, x0, disp=0, full_output=True, **kwds) 53 53 # itermon = kwds.pop('itermon',None)
Note: See TracChangeset
for help on using the changeset viewer.