python2 support fixes
This commit is contained in:
parent
a5854e31d7
commit
e36cf4b81e
Binary file not shown.
@ -1,6 +1,5 @@
|
||||
from __future__ import (absolute_import, division,
|
||||
print_function, unicode_literals)
|
||||
from builtins import *
|
||||
import warnings,operator
|
||||
warnings.filterwarnings("ignore")
|
||||
#Seed is needed to select the weights in linprog function.
|
||||
@ -39,8 +38,8 @@ def _remzero(coef,fun):
|
||||
nfun+=[f]
|
||||
return ncoef,nfun
|
||||
def slatex(formula): #fancy function which makes latex code more readable, but still correct
|
||||
formula=re.sub('\^{(.)}',r'^\1',latex(formula,fold_short_frac=True).replace(' ','').replace('\\left(','(').replace('\\right)',')'))
|
||||
return re.sub('\{(\(.+?\))\}',r'\1',formula)
|
||||
formula=re.sub(r'\^{(.)}',r'^\1',latex(formula,fold_short_frac=True).replace(' ','').replace('\\left(','(').replace('\\right)',')'))
|
||||
return re.sub(r'\{(\(.+?\))\}',r'\1',formula)
|
||||
def _writ2(coef,fun,variables):
|
||||
return slatex(S((str(coef)+'*'+'*'.join([str(x)+'^'+str(y) for x,y in zip(variables,fun)]))))
|
||||
def _writ(coef,fun,nullvar):
|
||||
@ -59,7 +58,7 @@ def _powr(formula):
|
||||
def fractioncancel(formula):
|
||||
#workaround for buggy cancel function
|
||||
num,den=fraction(cancel(formula/S('tmp')))
|
||||
den=den.subs('tmp','1')
|
||||
den=den.subs(S('tmp'),S('1'))
|
||||
return num,den
|
||||
def ssolve(formula,variables):
|
||||
#workaround for inconsistent solve function
|
||||
|
Loading…
Reference in New Issue
Block a user