Example #1
0
def parsedesc(string):
    expr, rest = string.split(' is a function of ')
    var_and_params = rest.split(' with parameter ')
    func = StringFunction(expr, independent_variable=var_and_params[0])
    if len(var_and_params) > 1:
        parameters = eval("dict(%s)" % var_and_params[1])
        func.set_parameters(**parameters)
    return func
Example #2
0
 def test_set_parameters(self):
     f = StringFunction('a+b*x', a=1)
     f.set_parameters(b=4)
     v = f(2)
     self.failUnlessEqual(v, 9, 'wrong value')