Parameters

Brian includes a simple tool for keeping track of parameters. If you only need something simple, then a dict or an empty class could be used. The point of the parameters class is that allows you to define a cascade of computed parameters that depend on the values of other parameters, so that changing one will automatically update the others. See the synfire chain example examples/sfc.py for a demonstration of how it can be used.

class brian.Parameters(**kwds)

A storage class for keeping track of parameters

Example usage:

p = Parameters(
    a = 5,
    b = 6,
    computed_parameters = '''
    c = a + b
    ''')
print p.c
p.a = 1
print p.c

The first print statement will give 11, the second gives 7.

Details:

Call as:

p = Parameters(...)

Where the ... consists of a list of keyword / value pairs (like a dict). Keywords must not start with the underscore _ character. Any keyword that starts with computed_ should be a string of valid Python statements that compute new values based on the given ones. Whenever a non-computed value is changed, the computed parameters are recomputed, in alphabetical order of their keyword names (so computed_a is computed before computed_b for example). Non-computed values can be accessed and set via p.x, p.x=1 for example, whereas computed values can only be accessed and not set. New parameters can be added after the Parameters object is created, including new computed_* parameters. You can ‘derive’ a new parameters object from a given one as follows:

p1 = Parameters(x=1)
p2 = Parameters(y=2,**p1)
print p2.x

Note that changing the value of x in p2 will not change the value of x in p1 (this is a copy operation).