Changeset 801
- Timestamp:
- 06/27/15 14:10:35 (11 months ago)
- Location:
- mystic
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
mystic/examples/TEST_ffitPP.py
r799 r801 43 43 44 44 if __name__ == '__main__': 45 from pathos.helpers import freeze_support 46 freeze_support() # help Windows use multiprocessing 45 47 solution = main() 46 48 print_solution(solution) -
mystic/examples/TEST_ffitPP_b.py
r799 r801 71 71 72 72 if __name__ == '__main__': 73 from pathos.helpers import freeze_support 74 freeze_support() # help Windows use multiprocessing 73 75 74 76 # number of local processors -
mystic/examples/buckshot_example06.py
r799 r801 25 25 from mystic.models.poly import chebyshev8coeffs 26 26 27 # if available, use a multiprocessingworker pool27 # if available, use a pathos worker pool 28 28 try: 29 29 from pathos.pools import ProcessPool as Pool … … 68 68 69 69 if __name__ == '__main__': 70 from pathos.helpers import freeze_support 71 freeze_support() # help Windows use multiprocessing 70 72 71 73 print "Powell's Method" -
mystic/examples/lattice_example06.py
r799 r801 25 25 from mystic.models.poly import chebyshev8coeffs 26 26 27 # if available, use a multiprocessingworker pool27 # if available, use a pathos worker pool 28 28 try: 29 29 from pathos.pools import ProcessPool as Pool … … 68 68 69 69 if __name__ == '__main__': 70 from pathos.helpers import freeze_support 71 freeze_support() # help Windows use multiprocessing 70 72 71 73 print "Powell's Method" -
mystic/examples/mpmap_desolve.py
r799 r801 49 49 50 50 if __name__=='__main__': 51 from pathos.helpers import freeze_support 52 freeze_support() # help Windows use multiprocessing 53 51 54 def print_solution(func): 52 55 print poly1d(func) -
mystic/examples/mpmap_desolve_rosen.py
r799 r801 50 50 51 51 if __name__=='__main__': 52 from pathos.helpers import freeze_support 53 freeze_support() # help Windows use multiprocessing 54 52 55 def print_solution(func): 53 56 print func -
mystic/examples/test_twistedgaussian3.py
r799 r801 21 21 22 22 def scemmap(Q): 23 from test_twistedgaussian import scem 23 24 Cs, As, Sk, Sak, target, cn = Q 24 25 niter = 1000 … … 33 34 # if available, use a multiprocessing worker pool 34 35 try: 36 from pathos.helpers import freeze_support 37 freeze_support() # help Windows use multiprocessing 35 38 from pathos.pools import ProcessPool as Pool 36 39 map = Pool().map -
mystic/mystic/abstract_solver.py
r795 r801 668 668 """save solver state to a restart file""" 669 669 import dill 670 fd = None 670 671 if filename is None: # then check if already has registered file 671 672 if self._state is None: # then create a new one 672 import tempfile 673 self._state = tempfile.mkstemp(suffix='.pkl')[-1] 673 import os, tempfile 674 fd, self._state = tempfile.mkstemp(suffix='.pkl') 675 os.close(fd) 674 676 filename = self._state 675 677 self._state = filename -
mystic/mystic/munge.py
r792 r801 46 46 params, cost = raw_to_support(params, cost) 47 47 except: 48 exec "from %s import params" % source 49 exec "from %s import cost" % source 48 params, cost = read_import(source+'.py', 'params', 'cost') 50 49 return params, cost 51 50 … … 145 144 146 145 def read_raw_file(file_in): 147 import re 148 file_in = re.sub('\.py*.$', '', file_in) #XXX: strip off .py* extension 149 exec "from %s import params as steps" % file_in 150 exec "from %s import cost as energy" % file_in 151 return steps, energy 146 steps, energy = read_import(file_in, "params", "cost") 147 return steps, energy # was 'from file_in import params as steps', etc 148 149 def read_import(file, *targets): 150 "import the targets; targets are name strings" 151 import re, os, sys 152 _dir, file = os.path.split(file) 153 file = re.sub('\.py*.$', '', file) #XXX: strip .py* extension 154 curdir = os.path.abspath(os.curdir) 155 sys.path.append('.') 156 results = [] 157 try: 158 if _dir: os.chdir(_dir) 159 if len(targets): 160 for target in targets: 161 exec "from %s import %s" % (file, target) 162 exec "results.append(%s)" % target 163 else: 164 exec "import %s" % file 165 exec "results.append(%s)" % file 166 except ImportError: 167 raise RuntimeError('File: %s not found' % file) 168 finally: 169 if _dir: os.chdir(curdir) 170 sys.path.pop() 171 if not len(results): return None 172 return results[-1] if (len(results) == 1) else results 152 173 153 174 def read_converge_file(file_in): -
mystic/mystic/tools.py
r793 r801 236 236 if str is not None: 237 237 print str 238 subprocess.call('stty raw', shell=True) 238 if sys.platform[:3] != 'win': 239 raw,cooked = 'stty raw','stty cooked' 240 else: 241 raw,cooked = '','' 242 subprocess.call(raw, shell=True) 239 243 a = sys.stdin.read(1) 240 subprocess.call( 'stty cooked', shell=True)244 subprocess.call(cooked, shell=True) 241 245 return a 242 246 else: -
mystic/scripts/support_hypercube_scenario.py
r776 r801 343 343 npts = parsed_opts.dim 344 344 if "None" == npts: # npts may have been logged 345 import re 346 file = re.sub('\.py*.$', '', parsed_args[0]) #XXX: strip .py* extension 347 exec "from %s import npts" % file 345 from mystic.munge import read_import 346 npts = read_import(parsed_args[0], 'npts') 348 347 else: npts = tuple(int(i) for i in dim.split(",")) # format is "1,1,1" 349 348 except: -
mystic/tests/test_symbolic_basic.py
r781 r801 128 128 129 129 x0 = [1., 1., 1.] 130 assert almostEqual(pf(cn(x0)), 0.0, tol=1e- 7)130 assert almostEqual(pf(cn(x0)), 0.0, tol=1e-2) 131 131 #XXX: implement: wrap_constraint( as_constraint(pf), sum, ctype='inner') ? 132 132
Note: See TracChangeset
for help on using the changeset viewer.