Changeset 832


Ignore:
Timestamp:
09/30/15 23:53:28 (8 months ago)
Author:
mmckerns
Message:

handle corner case of solve with '0*xN'; add additional print for verbose

Location:
mystic/mystic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • mystic/mystic/_symbolic.py

    r831 r832  
    391391 
    392392    if not permute: 
    393         return None if not solns[:1] else solns[0] 
     393        sol = None if not solns[:1] else solns[0] 
     394        return '' if sol and not sol.strip() else sol 
    394395    return tuple(solns) 
    395396 
     
    641642            soln = _solve_single(constraints, variables=variables, \ 
    642643                                 target=target, **kwds) 
     644            # for corner case where has something like: '0*xN' 
     645            if not soln or not soln.strip(): 
     646                if target in [None, False]: target = [] 
     647                elif isinstance(target, str): target = target.split(',') 
     648                else: target = list(target) 
     649                soln = _solve_single(constraints, variables=variables, \ 
     650                                     target=target[1:], **kwds) 
    643651        else: 
    644652            soln = _solve_linear(constraints, variables=variables, \ 
  • mystic/mystic/symbolic.py

    r831 r832  
    176176        res = solve(eqn.replace(cmp,'='), target=target, **kwds) 
    177177        _eqn = res.replace('=',cmp) 
    178         if verbose: print _eqn 
     178        if verbose: print 'in: %s\nout: %s' % (eqn, _eqn) 
    179179        if not cmp.count('<')+cmp.count('>'): 
    180180            return _eqn  
     
    182182        locals = kwds['locals'] if 'locals' in kwds else None 
    183183        if locals is None: locals = {} 
    184         locals.update(dict((var,rand()) for var in get_variables(res, vars))) 
     184        locals.update(dict((var,rand()) for var in get_variables(eqn, vars))) 
     185        if verbose: print locals 
    185186        locals_ = _locals.copy() 
    186187        locals_.update(locals) #XXX: allow this? 
Note: See TracChangeset for help on using the changeset viewer.