brainpy.tools package

ast2code module

ast2code(ast_node[, indent, line_length])

Decompiles an AST into Python code.

codes module

CodeLineFormatter()

format_code(code_string)

Get code lines from the string.

LineFormatterForTrajectory(fixed_vars)

format_code_for_trajectory(code_string, …)

Get _code lines from the string.

FindAtomicOp(var2idx)

find_atomic_op(code_line, var2idx)

FuncCallFinder(func_name)

replace_func(code, func_name)

DiffEquationAnalyser()

analyse_diff_eq(eq_code)

get_identifiers(expr[, include_numbers])

Return all the identifiers in a given string expr, that is everything that matches a programming language variable like expression, which is here implemented as the regexp \b[A-Za-z_][A-Za-z0-9_]*\b.

get_main_code(func)

Get the main function _code string.

get_line_indent(line[, spaces_per_tab])

indent(text[, num_tabs, spaces_per_tab, tab])

deindent(text[, num_tabs, spaces_per_tab, …])

word_replace(expr, substitutions)

Applies a dict of word substitutions.

is_lambda_function(func)

Check whether the function is a lambda function.

func_call(args)

get_func_source(func)

dicts module

DictPlus(*args, **kwargs)

Python dictionaries with advanced dot notation access.

class brainpy.tools.DictPlus(*args, **kwargs)[source]

Python dictionaries with advanced dot notation access.

For example:

>>> d = DictPlus({'a': 10, 'b': 20})
>>> d.a
10
>>> d['a']
10
>>> d.c  # this will raise a KeyError
KeyError: 'c'
>>> d.c = 30  # but you can assign a value to a non-existing item
>>> d.c
30
copy() → a shallow copy of D[source]
setdefault(key, default=None)[source]

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update([E, ]**F) → None. Update D from dict/iterable E and F.[source]

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

functions module

jit([func])

JIT user defined functions.

func_copy(f)

Make a deepcopy of a python function.

numba_func(func[, params])

get_func_name(func[, replace])

get_func_scope(func[, include_dispatcher])

Get function scope variables.

logger module

show_code_scope(code_scope[, ignores])

show_code_str(func_code)