Changeset 737 for mystic/mystic/abstract_solver.py
- Timestamp:
- 07/31/14 11:08:02 (22 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mystic/mystic/abstract_solver.py
r727 r737 78 78 import numpy 79 79 from numpy import inf, shape, asarray, absolute, asfarray 80 from mystic.tools import wrap_function, wrap_nested 80 from mystic.tools import wrap_function, wrap_nested, wrap_reducer 81 81 from mystic.tools import wrap_bounds, wrap_penalty, reduced 82 82 … … 146 146 self._constraints = lambda x: x 147 147 self._penalty = lambda x: 0.0 148 self._reducer = (None, False)148 self._reducer = None 149 149 self._cost = (None, None) 150 150 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 ? … … 220 220 (e.g. lambda x,y: x+y), taking two scalars and producing a scalar.""" 221 221 if not reducer: 222 self._reducer = (None, True)222 self._reducer = None 223 223 elif not callable(reducer): 224 224 raise TypeError, "'%s' is not a callable function" % reducer 225 else: #XXX: check for format: x' = reducer(x) ? 226 self._reducer = (reducer, arraylike) #XXX: bool(arraylike) ? 225 elif not arraylike: 226 self._reducer = wrap_reducer(reducer) 227 else: #XXX: check if is arraylike? 228 self._reducer = reducer 227 229 return 228 230 … … 578 580 cost = wrap_penalty(cost, self._penalty) 579 581 cost = wrap_nested(cost, self._constraints) 580 if self._reducer[0]: 581 cost = reduced(*self._reducer)(cost) #XXX: decorated? as wrap_*? 582 if self._reducer: 583 #cost = reduced(*self._reducer)(cost) # was self._reducer = (f,bool) 584 cost = reduced(self._reducer, arraylike=True)(cost) 582 585 # hold on to the 'wrapped' cost function 583 586 self._cost = (cost, ExtraArgs)
Note: See TracChangeset
for help on using the changeset viewer.