brian2tools.mdexport.expander module

Standard markdown expander class to expand Brian objects to markdown text using standard dictionary representation of baseexport

class brian2tools.mdexport.expander.MdExpander(brian_verbose=False, include_monitors=False, keep_initializer_order=False, author=None, add_meta=False, github_md=False)[source]

Bases: object

Build Markdown texts from run dictionary. The class contain various expand functions for corresponding Brian objects and get standard dictionary as argument to expand them with sentences in markdown format.

Note

If suppose the user would like to change the format or wordings in the exported model descriptions, one can derive from this standard markdown expander class to override the required changes in expand functions.

check_plural(iterable, singular_word=None, allow_constants=True, is_int=False)[source]

Function to attach plural form of the word by examining the following iterable

Parameters:
  • iterable (object with __iter__ attribute) – Object that has to be examined

  • singular_word (str, optional) – Word whose plural form has to searched in singular_plural_dict

  • allow_constants (bool, optional) – Whether to assume non iterable as singular, if set as True, the iterable argument must be an iterable

  • is_int (int, optional) – Check whether number 1 is passed, if > 1 return plural, by default set as False. Note: allow_constants should be True

create_md_string(net_dict, template_name)[source]

Create markdown text by checking the standard dictionary and call required expand functions and arrange the descriptions

expand_SpikeSource(source)[source]

Check whether subgroup dict and expand accordingly

Parameters:

source (str, dict) – Source group name or subgroup dictionary

expand_connector(connector)[source]

Expand synaptic connector from connector dictionary

Parameters:

connector (dict) – Dictionary representation of connector

expand_equation(var, equation)[source]

Expand Equation from equation dictionary

Parameters:
  • var (str) – Variable name

  • equation (dict) – Details of the equation

expand_equations(equations)[source]

Function to loop all equations

expand_event(event_name, event_details)[source]

Function to expand event dictionary

Parameters:
  • event_name (str) – name of the event

  • event_details (dict) – details of the event

expand_events(events)[source]

Expand function to loop through all events and call expand_event

expand_group(group, template_name)[source]

Expand group() header

Parameters:
  • group (groupname) – ex : - neurongrp,poisongrp ….

  • template_name (string) – full template name along with the group and template_type

expand_identifier(ident_key, ident_value)[source]

Expand identifer (key-value form)

Parameters:
  • ident_key (str) – Identifier name

  • ident_value (Quantity, str, dict) – Identifier value. Dictionary if identifer is of type either TimedArray or custom function

expand_identifiers(identifiers)[source]

Expand function to loop through identifiers and call expand_identifier

expand_initializer(initializer)[source]

Expand initializer from initializer dictionary

Parameters:

initializer (dict) – Dictionary representation of initializer

expand_network_header(net_dict)[source]

Expand function to write network header

expand_pathway(pathway)[source]

Expand SynapticPathway

Parameters:

pathway (dict) – SynapticPathway’s baseexport dictionary

expand_pathways(pathways)[source]

Loop through pathways and call expand_pathway

expand_run_header(run_dict, run_indx, single_run=False)[source]

Expand run() header

Parameters:
  • run_dict (dict) – run dictionary

  • run_indx (int) – Index of run

  • single_run (bool, optional) – Whether only single run() defined for the network

expand_runregularly(run_reg)[source]

Expand run_regularly from standard dictionary

Parameters:

run_reg (dict) – Standard dictionary representation for run_regularly()

expand_summed_variable(sum_variable)[source]

Expand Summed variable

Parameters:

sum_variabe (dict) – SummedVariable’s baseexport dictionary

expand_summed_variables(sum_variables)[source]

Loop through summed variables and call expand_summed_variable

prepare_array(arr, threshold=10, precision=2)[source]

Prepare arrays using numpy.array2string

Parameters:
  • arr (numpy.ndarray) – Numpy array to prepare

  • threshold (int, optional) – Threshold value to print all members

  • precision (int, optional) – Floating point precision

prepare_math_statements(statements, differential=False, separate=False, equals='←')[source]

Prepare statements to render in markdown format

Parameters:
  • statements (str) – String containing mathematical equations and statements

  • differential (bool, optional) – Whether should be treated as variable in differential equation

  • separate (bool, optional) – Whether lhs and rhs of the statement should be separated and rendered

  • equals (str, optional) – Equals operator, by default arrow from right to left

render_expression(expression, differential=False)[source]

Function to render mathematical expression using sympy.printing.latex

Parameters:
  • expression (str, Quantity) – Expression that has to rendered

  • differential (bool, optional) – Whether should be treated as variable in differential equation

Returns:

rend_exp – Markdown text for the expression

Return type:

str

set_template_dir(template_dir)[source]