Adds class specific .connect method with helpful message to the user.
moose.Function now supports named variables
Support arbitrarily named variable in the expression.
Currenty expression set on moose.Function can have variables named xi, yi etc. Using indices is supported by by default since it is straightforward to keep track of variables in memory. This PR enable support of arbitrary names in expr.
Here is an example of moose.Function. Also not the prettyprint of function expression. This is enabled by default if sympy is installed. Else normal text is printed.
# moose.connect(x0, 'output', fn1['A'], 'input') # old style.
x0.connect('output', fn1['A'], 'input')
# moose.connect(x1, 'output', fn1['B'], 'input') # old style
x1.connect('output', fn1['B'], 'nput') # typo.
moose : ERROR Could not find 'nput' on <moose.Variable: id=449, dataIndex=0, path=/fn1[0]/x[1]>.
Did you mean input?
Pretty print
If sympy >= 1.15, is already installed, a function's expression is printed
using sympy. For example:
root : WARNING Expression has been changed to MOOSE's form.
﹅ From,
﹅ Ca⋅k₂
﹅ k₁⋅ℯ ⋅cos(y₀) + sin(t)
﹅ to,
﹅ Ca⋅c₁
﹅ c₀⋅ℯ ⋅cos(y₀) + sin(t)
One can do so manually:
>>> f = moose.Function('f')
>>> f.compile('x^2+sqrt(y)+exp(x^y)')
>>> f.printUsingSympy()
⎛ y⎞
2 ⎝x ⎠
x + √ y + ℯ
>>>
.connect
method with helpful message to the user.moose.Function
now supports named variablesSupport arbitrarily named variable in the expression.
Currenty expression set on
moose.Function
can have variables namedxi
,yi
etc. Using indices is supported by by default since it is straightforward to keep track of variables in memory. This PR enable support of arbitrary names inexpr
.Here is an example of
moose.Function
. Also not the prettyprint of function expression. This is enabled by default ifsympy
is installed. Else normal text is printed.Alternative, one can use this syntax.
moose.connect is also wrapped
Pretty print
If sympy >= 1.15, is already installed, a function's expression is printed using sympy. For example:
root : WARNING Expression has been changed to MOOSE's form. ﹅ From, ﹅ Ca⋅k₂
﹅ k₁⋅ℯ ⋅cos(y₀) + sin(t) ﹅ to, ﹅ Ca⋅c₁
﹅ c₀⋅ℯ ⋅cos(y₀) + sin(t)
One can do so manually: