Fork me on GitHub

pyhrf.tools.aexpression module

class pyhrf.tools.aexpression.ArithmeticExpression(expression, **variables)

Bases: object

Mathematical Expression Evaluator class. You can set the expression member, set the functions, variables and then call evaluate() function that will return you the result of the mathematical expression given as a string.

addDefaultFunctions()

Add the following Python functions to be used in a mathemtical expression: acos asin atan atan2 ceil cos cosh degrees exp fabs floor fmod frexp hypot ldexp log log10 modf pow radians sin sinh sqrt tan tanh

addDefaultVariables()

Add e and pi to the list of defined variables.

call_if_func(x)
check()
evaluate()

Evaluate the mathematical expression given as a string in the expression member variable.

functions = None

Dictionary of variables that can be used in the expression.

getFunctionNames()

Return a List of defined function names in sorted order.

getVariableNames()

Return a List of defined variables names in sorted order.

setVariable(name, value)

Define the value of a variable defined by name

variables = None
exception pyhrf.tools.aexpression.ArithmeticExpressionNameError

Bases: exceptions.Exception

exception pyhrf.tools.aexpression.ArithmeticExpressionSyntaxError

Bases: exceptions.Exception