libSBML Python API  5.20.2
Loading...
Searching...
No Matches
doc_summary_of_astnode_methods Class Reference

Detailed Description

There are a number of methods for interrogating the type of an ASTNode and for testing whether a node belongs to a general category of constructs. The methods on ASTNode for this purpose are the following:
  • long ASTNode.getType() returns the type of this AST node.
  • bool ASTNode.isConstant() returns True if this AST node is a MathML constant (True, False, pi, exponentiale), False otherwise.
  • bool ASTNode.isBoolean() returns True if this AST node returns a Boolean value (by being either a logical operator, a relational operator, or the constant True or False).
  • bool ASTNode.isFunction() returns True if this AST node is a function (i.e., a MathML defined function such as exp or else a function defined by a FunctionDefinition in the Model).
  • bool ASTNode.isInfinity() returns True if this AST node is the special IEEE 754 value infinity.
  • bool ASTNode.isInteger() returns True if this AST node is holding an integer value.
  • bool ASTNode.isNumber() returns True if this AST node is holding any number.
  • bool ASTNode.isLambda() returns True if this AST node is a MathML lambda construct.
  • bool ASTNode.isLog10() returns True if this AST node represents the log10 function, specifically, that its type is AST_FUNCTION_LOG and it has two children, the first of which is an integer equal to 10.
  • bool ASTNode.isLogical() returns True if this AST node is a logical operator (and, or, not, xor).
  • bool ASTNode.isName() returns True if this AST node is a user-defined name or (in SBML Level 2) one of the two special csymbol constructs "delay" or "time".
  • bool ASTNode.isNaN() returns True if this AST node has the special IEEE 754 value "not a number" (NaN).
  • bool ASTNode.isNegInfinity() returns True if this AST node has the special IEEE 754 value of negative infinity.
  • bool ASTNode.isOperator() returns True if this AST node is an operator (e.g., +, -, etc.)
  • bool ASTNode.isPiecewise() returns True if this AST node is the MathML piecewise function.
  • bool ASTNode.isRational() returns True if this AST node is a rational number having a numerator and a denominator.
  • bool ASTNode.isReal() returns True if this AST node is a real number (specifically, AST_REAL_E or AST_RATIONAL).
  • bool ASTNode.isRelational() returns True if this AST node is a relational operator.
  • bool ASTNode.isSqrt() returns True if this AST node is the square-root operator
  • bool ASTNode.isUMinus() returns True if this AST node is a unary minus.
  • bool ASTNode.isUnknown() returns True if this AST node's type is unknown.

Programs manipulating AST node structures should check the type of a given node before calling methods that return a value from the node. The following are the ASTNode object methods available for returning values from nodes:

Of course, all of this would be of little use if libSBML didn't also provide methods for setting the values of AST node objects! And it does. The methods are the following:

  • ASTNode.setCharacter(char) sets the value of this ASTNode to the given character. If character is one of +, -, *, / or ^, the node type will be to the appropriate operator type. For all other characters, the node type will be set to AST_UNKNOWN
  • ASTNode.setName(string) sets the value of this AST node to the given name. The node type will be set (to AST_NAME) only if the AST node was previously an operator (isOperator(node) != 0) or number (isNumber(node) != 0). This allows names to be set for AST_FUNCTIONs and the like.
  • ASTNode.setValue(int) sets the value of the node to the given integer. Equivalent to the next method.
  • ASTNode.setValue(long) sets the value of the node to the given integer.
  • ASTNode.setValue(long, long) sets the value of this ASTNode to the given rational in two parts: the numerator and denominator. The node type is set to AST_RATIONAL.
  • ASTNode.setValue(float) sets the value of this ASTNode to the given real (float) and sets the node type to AST_REAL.
  • ASTNode.setValue(float, long) sets the value of this ASTNode to the given real (float) in two parts: the mantissa and the exponent. The node type is set to AST_REAL_E.

Finally, ASTNode also defines some miscellaneous methods for manipulating ASTs: