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