Automatic Model Documentation¶

class
brian.experimental.model_documentation.
DocumentWriter
¶ Base class for documenting a network. Already takes care of assigning labels to objects if none are given.

document_connections
(connections)¶ Document the connections of the network (including
SpikeMonitor
etc. as they are modeled asConnection
objects).

document_group
(group)¶ Document a single
NeuronGroup
group. Will normally be called for every group bydocument_groups()
.

document_groups
(groups)¶ Document all
NeuronGroup
groups. Should normally calldocument_group()
for every group.

document_network
(net=None, labels=None, sim=True, groups=True, connections=True, operations=True, graph_connections=False)¶ Documents the network net, if not network is given, a
MagicNetwork
is automatically created and documented, i.e. if you are running scripts without any explicit network (you use run(…) instead of net.run(…)), you can simply call writer.document_network().

document_operation
(operation)¶ Document a single
NetworkOperation
operation. Should normally be called bydocument_operations()
for every operation.

document_operations
(operations)¶ Document all
NetworkOperation
operations (includingStateMonitor
etc. as they are modeled asNetworkOperation
objects). Should normally calldocument_operation()
for every operation.

document_sim
(network)¶ Document some general properties of the network, e.g. the timestep used in the simulation.

graph_connections
(connections, groups)¶ Draw a graph visualizing the connection structure of the network.

intro
()¶ Is called before any other output function, useful for the start of an HTML or LaTeX document.

outro
()¶ Is called after all other output function, useful for the end of an HTML or LaTeX document.

static
to_sympy_expression
(eq_string)¶ Simple helper function for converting an Equation string eq_string (only the right hand side of an equation) into a sympy expression by calling x = Symbol(‘x’) for every variable x in the equation.


class
brian.experimental.model_documentation.
TextDocumentWriter
(**kwargs)¶ Documents the network by printing to stdout, uses sympy for formatting the equations (including nice Unicode symbols)

class
brian.experimental.model_documentation.
LaTeXDocumentWriter
(**kwargs)¶ Documents the network by printing LaTeX code to stdout. Prints a full document (i.e. including preamble etc.). The resulting LaTeX file needs the amsmath package.
Note that if you use the graph_connections=True option, you additionally need the tikz and dot2texi packages (part of texlivecore and texlivepictures on Linux systems) and the dot2tex tool. To make the conversion from dot code to LaTeX automatically happen on document creation you have to pass the –shellescape option to your LaTeX call, e.g. pdflatex –shellescape network_doc.tex

static
format_equation
(lhs, rhs, unit)¶ Helper function to convert an equation consisting of two strings for the left respectively the right hand side of an equation (lhs and rhs) and a Brian
Unit
unit into a LaTeX expression aligning on the equality sign for amsmath’s align environment.

static
latex_equation
(eq_string)¶ Helper function to convert the right hand side of an equation string eq_string to a LaTeX expression (not a full equation in LaTeX terms) using sympy.

static
latex_equations
(eqs)¶ Convert Brian equations (either a – possibly multiline – string or an
Equation
object) eqs into a LaTeX equation using amsmath’s align environment.

static

brian.experimental.model_documentation.
document_network
(net=None, output='text', **kwargs)¶ Convenience method for documenting a network without having to construct a
DocumentWriter
object first.If no network net is given, a
MagicNetwork
is automatically created and documented. The output argument should be either text (the default) or latex. Any further keyword arguments are passed on to the respectiveDocumentWriter
.

brian.experimental.model_documentation.
labels_from_namespace
(namespace)¶ Creates a labels dictionary that can be handed over to the document_network from a given namespace. Would typically be called like this: net.document_network(labels=labels_from_namespace(locals())) This allows document_network to use the variable names used in the Python code as the short labels, making it easier to link the model description and the actual code.