1234567891011121314151617181920212223242526272829303132333435 |
- def getFuncExpr(exprTok, eqnVars, graphVars):
- """Allocates variables in equation to graph variables to give final function compatible for plotting
- Arguments:
- exprTok {list} -- expression tokens
- eqnVars {list} -- variables in equation
- graphVars {list} -- variables for plotting
- Returns:
- expr {numpy.array(2D)/function(3D)} -- expression converted to compatible data type for plotting
- """
- expr = 0
- coeff = 1
- for token in exprTok:
- if isinstance(token, Variable):
- varProduct = 1
- for value, power in zip(token.value, token.power):
- varProduct *= graphVars[eqnVars.index(value)]**power
- expr += coeff * token.coefficient * varProduct
- elif isinstance(token, Constant):
- expr += coeff * token.value
- elif isinstance(token, FuncOp):
- pass
- elif isinstance(token, Binary) and token.value == '-':
- coeff = -1
- elif isinstance(token, Binary) and token.value == '+':
- coeff = 1
- return expr
- #######
- # GUI #
- #######
|