Exemplo n.º 1
0
def find_names_in_ast(ast: libsbml.ASTNode,
                      names: Optional[List[str]] = None) -> List[str]:
    """Find all names in given astnode.

    Names are the variables in the formula.

    :param ast:
    :param names:
    :return:
    """
    if names is None:
        names = []

    # name for this node
    if ast.getType() == libsbml.AST_NAME:
        names.append(ast.getName())

    for k in range(ast.getNumChildren()):
        ast_child = ast.getChild(k)
        find_names_in_ast(ast_child, names)

    return names
Exemplo n.º 2
0
def ast_info(ast: libsbml.ASTNode) -> None:
    """Print ASTNode information."""
    print(ast)
    print(ast.getType(), ast.getName())