Changeset 767


Ignore:
Timestamp:
11/11/14 15:02:35 (18 months ago)
Author:
mmckerns
Message:

convert tuple of degenerate solved values to dict format in _solve_single

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mystic/mystic/_symbolic.py

    r760 r767  
    355355    if permute or not target: #XXX: the goal is solving *only one* equation 
    356356        code += '_xlist = %s\n' % ','.join(targeted) 
    357         code += '_xlist = [symsol(['+eqlist+'], [i]) for i in _xlist]\n' 
     357        code += '_elist = [symsol(['+eqlist+'], [i]) for i in _xlist]\n' 
     358        code += '_elist = [i if isinstance(i, dict) else {j:i[-1][-1]} for j,i in zip(_xlist,_elist)]\n' 
    358359        code += 'soln = {}\n' 
    359         code += '[soln.update(i) for i in _xlist if i]\n' 
     360        code += '[soln.update(i) for i in _elist if i]\n' 
    360361    else: 
    361362        code += 'soln = symsol([' + eqlist + '], [' + target[0] + '])\n' 
    362363       #code += 'soln = symsol([' + eqlist + '], [' + targeted[0] + '])\n' 
     364        code += 'soln = soln if isinstance(soln, dict) else {' + target[0] + ': soln[-1][-1]}\n' 
    363365    ######################################################################## 
    364366 
     
    535537        # returns: {x0: f(xn,...), x1: f(xn,...), ...} 
    536538        _code += 'soln = symsol([' + eqlist + '], [' + xlist + '])' 
     539        #XXX: need to convert/check soln similarly as in _solve_single ? 
    537540        if verbose: print _code 
    538541        _code = compile(_code, '<string>', 'exec') 
Note: See TracChangeset for help on using the changeset viewer.