Changeset 620 for branches


Ignore:
Timestamp:
12/20/12 15:39:12 (3 years ago)
Author:
mmckerns
Message:

pass constraint and penalty informative docstring built from underlying funcs

Location:
branches/decorate
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/decorate/_symbolic.py

    r619 r620  
    240240        >>> print simplify_symbolic(equation, target='x2') 
    241241        x2 = 3.0 + x1*x3 
     242 
     243Further Inputs: 
     244    locals -- a dictionary of additional variables used in the symbolic 
     245        constraints equations, and their desired values. 
    242246""" #XXX: an expanded version of this code is found in build_constraints XXX# 
    243247    # for now, we abort on multi-line equations or inequalities 
     
    376380        >>> f([1.0, 0.0, 0.0, 1.0]) 
    377381        [1.0, 0.0, -1.0, -0.5] 
     382 
     383Further Inputs: 
     384    locals -- a dictionary of additional variables used in the symbolic 
     385        constraints equations, and their desired values. 
    378386""" 
    379387    """ 
    380 Further Inputs: 
    381388    guess -- list of parameter values proposed to solve the constraints. 
    382389    lower_bounds -- list of lower bounds on solution values. 
     
    639646        >>> f([1.0, 0.0, 0.0, 1.0]) 
    640647        [1.0, 0.0, -1.0, -0.5] 
     648 
     649Further Inputs: 
     650    locals -- a dictionary of additional variables used in the symbolic 
     651        constraints equations, and their desired values. 
    641652""" 
    642653    """ 
    643 Further Inputs: 
    644654    guess -- list of parameter values proposed to solve the constraints. 
    645655    lower_bounds -- list of lower bounds on solution values. 
     
    699709        >>> f([1.0, 2.0, 3.0]) 
    700710        [1.0, -0.33333333333333204, 3.0] 
     711 
     712Further Inputs: 
     713    locals -- a dictionary of additional variables used in the symbolic 
     714        constraints equations, and their desired values. 
    701715""" 
    702716    """ 
    703 Further Inputs: 
    704717    guess -- list of parameter values proposed to solve the constraints. 
    705718    lower_bounds -- list of lower bounds on solution values. 
  • branches/decorate/symbolic.py

    r616 r620  
    456456        code = """ 
    457457def %(container)s_%(name)s(x): return eval('%(equation)s') 
     458%(container)s_%(name)s.__name__ = '%(container)s' 
    458459%(container)s_%(name)s.__doc__ = '%(equation)s'""" % fdict 
    459460        #XXX: should locals just be the above dict of functions, or should we... 
     
    531532    exec('%(equation)s') 
    532533    return x 
     534%(container)s_%(name)s.__name__ = '%(container)s' 
    533535""" % fdict #XXX: better, check if constraint satisfied... if not, then solve 
    534536        #XXX: should locals just be the above dict of functions, or should we... 
     
    590592    # iterate through penalties, building a compound penalty function 
    591593    pf = lambda x:0.0 
     594    pfdoc = "" 
    592595    for penalty, condition in zip(ptype, conditions): 
     596        pfdoc += "%s: %s\n" % (penalty.__name__, condition.__doc__) 
    593597        apply = penalty(condition, **kwds) 
    594598        pf = apply(pf) 
     599    pf.__doc__ = pfdoc.rstrip('\n') 
     600    pf.__name__ = 'penalty' 
    595601    return pf 
    596602 
     
    657663    # iterate through solvers, building a compound constraints solver 
    658664    cf = lambda x:x 
     665    cfdoc = "" 
    659666    for wrapper, condition in zip(ctype, conditions): 
     667        cfdoc += "%s: %s\n" % (wrapper.__name__, condition.__doc__) 
    660668        apply = wrapper(condition, **kwds) 
    661669        cf = apply(cf) 
     670    cf.__doc__ = cfdoc.rstrip('\n') 
     671    cf.__name__ = 'constraint' 
    662672    return cf 
    663673 
Note: See TracChangeset for help on using the changeset viewer.