- Timestamp:
- 02/16/15 16:43:28 (15 months ago)
- Location:
- mystic
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
mystic/mystic/abstract_solver.py
r776 r781 590 590 return cost 591 591 592 def _bootstrap_ decorate(self, cost=None, ExtraArgs=None):592 def _bootstrap_objective(self, cost=None, ExtraArgs=None): 593 593 """HACK to enable not explicitly calling _RegisterObjective""" 594 594 args = None … … 696 696 """ 697 697 # HACK to enable not explicitly calling _RegisterObjective 698 cost = self._bootstrap_ decorate(cost, ExtraArgs)698 cost = self._bootstrap_objective(cost, ExtraArgs) 699 699 # process and activate input settings 700 700 settings = self._process_inputs(kwds) -
mystic/mystic/differential_evolution.py
r776 r781 220 220 Note that ExtraArgs should be a *tuple* of extra arguments""" 221 221 # HACK to enable not explicitly calling _RegisterObjective 222 cost = self._bootstrap_decorate(cost, ExtraArgs) 222 cost = self._bootstrap_objective(cost, ExtraArgs) 223 # process and activate input settings 224 kwds['strategy'] = strategy # override default strategy with None 225 settings = self._process_inputs(kwds) 226 for key in settings: 227 exec "%s = settings['%s']" % (key,key) 223 228 224 229 if not len(self._stepmon): # do generation = 0 … … 372 377 Note that ExtraArgs should be a *tuple* of extra arguments""" 373 378 # HACK to enable not explicitly calling _RegisterObjective 374 cost = self._bootstrap_decorate(cost, ExtraArgs) 379 cost = self._bootstrap_objective(cost, ExtraArgs) 380 # process and activate input settings 381 kwds['strategy'] = strategy # override default strategy with None 382 settings = self._process_inputs(kwds) 383 for key in settings: 384 exec "%s = settings['%s']" % (key,key) 375 385 376 386 if not len(self._stepmon): # do generation = 0 -
mystic/mystic/scipy_optimize.py
r776 r781 145 145 Note that ExtraArgs should be a *tuple* of extra arguments""" 146 146 # HACK to enable not explicitly calling _RegisterObjective 147 cost = self._bootstrap_ decorate(cost, ExtraArgs)147 cost = self._bootstrap_objective(cost, ExtraArgs) 148 148 # process and activate input settings 149 149 settings = self._process_inputs(kwds) … … 459 459 Note that ExtraArgs should be a *tuple* of extra arguments""" 460 460 # HACK to enable not explicitly calling _RegisterObjective 461 cost = self._bootstrap_ decorate(cost, ExtraArgs)461 cost = self._bootstrap_objective(cost, ExtraArgs) 462 462 # process and activate input settings 463 463 settings = self._process_inputs(kwds) -
mystic/mystic/tools.py
r776 r781 142 142 # convienence for passing in 'numpy' 143 143 if module == 'numpy': module = 'numpy.random' 144 import importlib 145 rng = importlib.import_module(module) 144 try: 145 import importlib 146 rng = importlib.import_module(module) 147 except ImportError: 148 rng = __import__(module, fromlist=module.split('.')[-1:]) 146 149 elif module.__name__ == 'numpy': # convienence for passing in numpy 147 150 from numpy import random as rng -
mystic/tests/test_compound_termination.py
r776 r781 69 69 70 70 assert len(_v) == len(_c) == len(_n) == 1 71 assert _v.index(v) == _c.index(c) == _n.index(n) == 072 assert _v.count(v) == _c.count(c) == _n.count(n) == 171 assert list(_v).index(v) == list(_c).index(c) == list(_n).index(n) == 0 72 assert list(_v).count(v) == list(_c).count(c) == list(_n).count(n) == 1 73 73 assert v in _v and c in _c and n in _n 74 74 assert v in v_and_c and c in v_and_c … … 84 84 assert c in c_and_v and v in c_and_v 85 85 assert c in c_or_v and v in c_or_v 86 assert c_and_v.index(c) == v_and_c.index(v)87 assert c_and_v.index(v) == v_and_c.index(c)88 assert c_or_v.index(c) == v_or_c.index(v)89 assert c_or_v.index(v) == v_or_c.index(c)86 assert list(c_and_v).index(c) == list(v_and_c).index(v) 87 assert list(c_and_v).index(v) == list(v_and_c).index(c) 88 assert list(c_or_v).index(c) == list(v_or_c).index(v) 89 assert list(c_or_v).index(v) == list(v_or_c).index(c) 90 90 assert c_and_v in c_or__c_and_v and _c in c_or__c_and_v 91 91 -
mystic/tests/test_symbolic.py
r776 r781 62 62 def test_solve_constraint(): 63 63 64 # sympy can no longer do "spread([x0,x1])"... so use "x1 - x0" 64 65 constraints = """ 65 spread([x0,x1]) - 1.0 = mean([x0,x1])66 (x1 - x0) - 1.0 = mean([x0,x1]) 66 67 mean([x0,x1,x2]) = x2""" 67 68 68 from mystic.math.measures import mean , spread69 from mystic.math.measures import mean 69 70 _constraints = solve(constraints) 70 71 solv = generate_solvers(_constraints) … … 73 74 assert all(x) == all([1.0, 5.0, 3.0]) 74 75 assert mean(x) == x[2] 75 assert spread(x[:-1]) - 1.0 == mean(x[:-1])76 assert (x[1] - x[0]) - 1.0 == mean(x[:-1]) 76 77 77 78 -
mystic/tests/test_symbolic_basic.py
r776 r781 125 125 # print "symbolic string:\n", constraints_string.rstrip() 126 126 pf = generate_penalty(generate_conditions(constraints_string)) 127 cn = as_constraint(pf) 127 128 128 @inner(as_constraint(pf)) 129 def cf(x): 130 return sum(x) 131 129 x0 = [1., 1., 1.] 130 assert almostEqual(pf(cn(x0)), 0.0, tol=1e-7) 132 131 #XXX: implement: wrap_constraint( as_constraint(pf), sum, ctype='inner') ? 133 # print "c = constraints wrapped around sum(x)"134 x0 = [1., 1., 1.]135 # print "c(%s): %s\n" % (x0, cf(x0))136 assert almostEqual(cf(x0), 0.133687558709, tol=1e-15)137 132 138 133 def test_varnamelist():
Note: See TracChangeset
for help on using the changeset viewer.