parameters

Data

__name__ = NeuroTools.parameters

Functions

check_dependency(name)

contains_instance(collection, cls)

isiterable(x)

nesteddictflatten(d, separator='.')

Return a flattened version of a nested dict structure.

Composite keys are created by joining each key to the key of the parent dict using separator.

nesteddictwalk(d, separator='.')

Walk a nested dict structure, using a generator.

Composite keys are created by joining each key to the key of the parent dict using separator.

string_table(tablestring)

Convert a table written as a multi-line string into a dict of dicts.

urlparse(url, scheme=, allow_fragments=True)

Parse a URL into 6 components: <scheme>://<netloc>/<path>;<params>?<query>#<fragment> Return a 6-tuple: (scheme, netloc, path, params, query, fragment). Note that we don't break the components up in smaller bits (e.g. netloc is a single string) and we don't expand % escapes.

Classes

GammaDist

gamma.pdf(x,a,b) = x**(a-1)*exp(-x/b)/gamma(a)/b**a

Yields strictly positive numbers. Generally the distribution is implemented by scipy.stats.gamma.pdf(x/b,a)/b For more info, in ipython type:

? scipy.stats.gamma

__eq__(self, o)

__init__(self, mean=None, std=None, repr_mode='ms', **params)

repr_mode specifies how the dist is displayed, either mean,var ('ms', the default) or a,b ('ab')

from_stats(self, vals, bias=0.0, expand=1.0)

mean(self)

next(self, n=1)

std(self)


NormalDist

normal distribution with parameters mean + std

Generally the distribution is implemented by scipy.stats.gamma.pdf(x/b,a)/b

For more info, in ipython type:

? scipy.stats.gamma

__eq__(self, o)

__init__(self, mean=0.0, std=1.0)

from_stats(self, vals, bias=0.0, expand=1.0)

next(self, n=1)


Parameter

__init__(self, value, units=None, name=)


ParameterDist

__eq__(self, o)

__init__(self, **params)

from_stats(self, vals, bias=0.0, expand=1.0)

next(self, n=1)


ParameterRange

A class for specifying a list of possible values for a given parameter.

The value must be an iterable. It acts like a Parameter, but .next() can be called to iterate through the values

__eq__(self, o)

__init__(self, value, units=None, name=, shuffle=False)

__iter__(self)

__len__(self)

next(self)


ParameterSet

A class to manage hierarchical parameter sets.

Usage example:

sim_params = ParameterSet({'dt': 0.1, 'tstop': 1000.0}) exc_cell_params = ParameterSet("http://neuralensemble.org/svn/!NeuroTools/example.params") inh_cell_params = ParameterSet({'tau_m': 15.0, 'cm': 0.5}) network_params = ParameterSet({'excitatory_cells': exc_cell_params, 'inhibitory_cells': inh_cell_params}) P = ParameterSet({'sim': sim_params, 'network': network_params}) P.sim.dt

0.1

P.network.inhibitory_cells.tau_m

15.0

print P.pretty()

__getattr__(self, name)

Allow accessing parameters using dot notation.

__getitem__(self, name)

Modified get that detects dots '.' in the names and goes down the nested tree to find it

__getstate__(self)

For pickling.

__init__(self, initialiser, label=None)

__setitem__(self, name, value)

Modified set that detects dots '.' in the names and goes down the nested tree to set it

__sub__(self, other)

Return the difference between this ParameterSet and another. Not yet properly implemented.

as_dict(self)

returns a copy of the ParameterSet tree structure as a nested dictionary

flat(self)

flatten(self)

pretty(self, indent=' ', expand_urls=False)

Return a unicode string representing the structure of the !ParameterSet. evaluating the string should recreate the object.

save(self, url=None, expand_urls=False)

Write the parameter set to a text file.

The text file syntax is open to discussion. My idea is that it should be valid Python code, preferably importable as a module.

If url is None, try to save to self._url (if it is not None), otherwise save to url.

tree_copy(self)

returns a copy of the ParameterSet tree structure. Nodes are not copied, but re-referenced.

read_from_str(str)

ParameterSet definition str should be a Python dict definition string, containing objects of types int, float, str, list, dict plus the classes defined in this module, Parameter, !ParameterRange, etc. No other object types are allowed, except the function url('some_url'), e.g.: { 'a' : {'A': 3, 'B': 4}, 'b' : [1,2,3], 'c' : 'hello world', 'd' : url('http://example.com/my_cool_parameter_set') }

This is largely the JSON (www.json.org) format, but with extra keywords in the Namespace such as ParameterRange, GammaDist, etc.

Python also supports specifying dictionaries as follows:

dict(x=1,y=2)

But usage of such un-JSON-ly idioms should likely be discouraged... __cmp__ = <slot wrapper '__cmp__' of 'dict' objects>

__contains__ = <method '__contains__' of 'dict' objects>

__delitem__ = <slot wrapper '__delitem__' of 'dict' objects>

__eq__ = <slot wrapper '__eq__' of 'dict' objects>

__ge__ = <slot wrapper '__ge__' of 'dict' objects>

__gt__ = <slot wrapper '__gt__' of 'dict' objects>

__iter__ = <slot wrapper '__iter__' of 'dict' objects>

__le__ = <slot wrapper '__le__' of 'dict' objects>

__len__ = <slot wrapper '__len__' of 'dict' objects>

__lt__ = <slot wrapper '__lt__' of 'dict' objects>

__ne__ = <slot wrapper '__ne__' of 'dict' objects>

clear = <method 'clear' of 'dict' objects>

copy = <method 'copy' of 'dict' objects>

fromkeys = <built-in method fromkeys of type object at 0x220e460>

get = <method 'get' of 'dict' objects>

has_key = <method 'has_key' of 'dict' objects>

items = <method 'items' of 'dict' objects>

iteritems = <method 'iteritems' of 'dict' objects>

iterkeys = <method 'iterkeys' of 'dict' objects>

itervalues = <method 'itervalues' of 'dict' objects>

keys = <method 'keys' of 'dict' objects>

non_parameter_attributes = ['_url', 'label', 'names', 'parameters', 'flat', 'flatten', 'non_parameter_attributes']

pop = <method 'pop' of 'dict' objects>

popitem = <method 'popitem' of 'dict' objects>

setdefault = <method 'setdefault' of 'dict' objects>

update = <method 'update' of 'dict' objects>

values = <method 'values' of 'dict' objects>


ParameterSpace

A collection of ParameterSets, representing multiple points in parameter space. Created by putting ParameterRange and/or ParameterDist objects within a ParameterSet.

__getattr__(self, name)

Allow accessing parameters using dot notation.

__getitem__(self, name)

Modified get that detects dots '.' in the names and goes down the nested tree to find it

__getstate__(self)

For pickling.

__init__(self, initialiser, label=None)

__setitem__(self, name, value)

Modified set that detects dots '.' in the names and goes down the nested tree to set it

__sub__(self, other)

Return the difference between this ParameterSet and another. Not yet properly implemented.

as_dict(self)

returns a copy of the ParameterSet tree structure as a nested dictionary

dist_keys(self)

returns the list of keys for those elements which are ParameterDists

flat(self)

flatten(self)

iter_inner(self, copy=False)

An iterator of the ParameterSpace which yields ParameterSets with all combinations of ParameterRange elements

iter_inner_range_keys(self, keys, copy=False)

An iterator of the ParameterSpace which yields ParameterSets with all combinations of ParameterRange elements which are given by the keys list

Note: each newly yielded value is one and the same object so storing the returned values results in a collection of many of the lastly yielded object.

copy=True causes each yielded object to be a newly created object, but be careful because this is spawning many dictionaries!

iter_range_key(self, range_key)

An iterator of the ParameterSpace which yields the ParameterSet with the ParameterRange given by key replaced with each of its values

num_conditions(self)

Returns the number of ParameterSets that will be returned by the iter_inner() method.

parameter_space_dimension_labels(self)

returns the dimentions and labels of the keys for those elements which are ParameterRanges range_keys are sorted to ensure same ordering each time.

parameter_space_index(self, current_experiment)

returns the index of the current experiment in the dimension of the parameter space i.e. parameter space dimension: [2,3] i.e. index: (1,0)

Example:

p = ParameterSet({}) p.b = ParameterRange([1,2,3]) p.a = ParameterRange(['p','y','t','h','o','n'])

results_dim, results_label = p.parameter_space_dimension_labels()

results = numpy.empty(results_dim) for experiment in p.iter_inner(): index = p.parameter_space_index(experiment) results[index] = 2.

pretty(self, indent=' ', expand_urls=False)

Return a unicode string representing the structure of the !ParameterSet. evaluating the string should recreate the object.

range_keys(self)

returns the list of keys for those elements which are ParameterRanges

realize_dists(self, n=1, copy=False)

For each ParameterDist, realize the distribution and yield the result

If copy==True, causes each yielded object to be a newly created object, but be careful because this is spawning many dictionaries!

save(self, url=None, expand_urls=False)

Write the parameter set to a text file.

The text file syntax is open to discussion. My idea is that it should be valid Python code, preferably importable as a module.

If url is None, try to save to self._url (if it is not None), otherwise save to url.

tree_copy(self)

returns a copy of the ParameterSet tree structure. Nodes are not copied, but re-referenced.

read_from_str(str)

ParameterSet definition str should be a Python dict definition string, containing objects of types int, float, str, list, dict plus the classes defined in this module, Parameter, !ParameterRange, etc. No other object types are allowed, except the function url('some_url'), e.g.: { 'a' : {'A': 3, 'B': 4}, 'b' : [1,2,3], 'c' : 'hello world', 'd' : url('http://example.com/my_cool_parameter_set') }

This is largely the JSON (www.json.org) format, but with extra keywords in the Namespace such as ParameterRange, GammaDist, etc.

Python also supports specifying dictionaries as follows:

dict(x=1,y=2)

But usage of such un-JSON-ly idioms should likely be discouraged...

__cmp__ = <slot wrapper '__cmp__' of 'dict' objects>

__contains__ = <method '__contains__' of 'dict' objects>

__delitem__ = <slot wrapper '__delitem__' of 'dict' objects>

__eq__ = <slot wrapper '__eq__' of 'dict' objects>

__ge__ = <slot wrapper '__ge__' of 'dict' objects>

__gt__ = <slot wrapper '__gt__' of 'dict' objects>

__iter__ = <slot wrapper '__iter__' of 'dict' objects>

__le__ = <slot wrapper '__le__' of 'dict' objects>

__len__ = <slot wrapper '__len__' of 'dict' objects>

__lt__ = <slot wrapper '__lt__' of 'dict' objects>

__ne__ = <slot wrapper '__ne__' of 'dict' objects>

clear = <method 'clear' of 'dict' objects>

copy = <method 'copy' of 'dict' objects>

fromkeys = <built-in method fromkeys of type object at 0x220e7b0>

get = <method 'get' of 'dict' objects>

has_key = <method 'has_key' of 'dict' objects>

items = <method 'items' of 'dict' objects>

iteritems = <method 'iteritems' of 'dict' objects>

iterkeys = <method 'iterkeys' of 'dict' objects>

itervalues = <method 'itervalues' of 'dict' objects>

keys = <method 'keys' of 'dict' objects>

non_parameter_attributes = ['_url', 'label', 'names', 'parameters', 'flat', 'flatten', 'non_parameter_attributes']

pop = <method 'pop' of 'dict' objects>

popitem = <method 'popitem' of 'dict' objects>

setdefault = <method 'setdefault' of 'dict' objects>

update = <method 'update' of 'dict' objects>

values = <method 'values' of 'dict' objects>


ParameterTable

A sub-class of ParameterSet that can represent a table of parameters.

i.e., it is limited to one-level of nesting, and each sub-dict must have the same keys. In addition to the possible initialisers for ParameterSet, a ParameterTable can be initialised from a multi-line string, e.g.

pt = ParameterTable(

... # col1 col2 col3 ... row1 1 2 3 ... row2 4 5 6 ... row3 7 8 9 ... )

pt.row2.col3

6.0

pt.column('col1')

{'row1': 1.0, 'row2': 4.0, 'row3': 7.0}

pt.transpose().col3.row2

6.0

__getattr__(self, name)

Allow accessing parameters using dot notation.

__getitem__(self, name)

Modified get that detects dots '.' in the names and goes down the nested tree to find it

__getstate__(self)

For pickling.

__init__(self, initialiser, label=None)

__setitem__(self, name, value)

Modified set that detects dots '.' in the names and goes down the nested tree to set it

__sub__(self, other)

Return the difference between this ParameterSet and another. Not yet properly implemented.

as_dict(self)

returns a copy of the ParameterSet tree structure as a nested dictionary

column(self, column_label)

Returns a ParameterSet object containing the requested column.

column_labels(self)

Return a list of column labels.

columns(self)

Return a list of (column_label, column) pairs, as 2-tuples.

flat(self)

flatten(self)

pretty(self, indent=' ', expand_urls=False)

Return a unicode string representing the structure of the !ParameterSet. evaluating the string should recreate the object.

row(self, row_label)

Returns a ParameterSet object containing the requested row.

save(self, url=None, expand_urls=False)

Write the parameter set to a text file.

The text file syntax is open to discussion. My idea is that it should be valid Python code, preferably importable as a module.

If url is None, try to save to self._url (if it is not None), otherwise save to url.

table_string(self)

Returns the table as a string, suitable for being used as the initialiser for a new !ParameterTable.

transpose(self)

Return a new !ParameterTable object with the same data as the current one but with rows and columns swapped.

tree_copy(self)

returns a copy of the ParameterSet tree structure. Nodes are not copied, but re-referenced.

read_from_str(str)

ParameterSet definition str should be a Python dict definition string, containing objects of types int, float, str, list, dict plus the classes defined in this module, Parameter, !ParameterRange, etc. No other object types are allowed, except the function url('some_url'), e.g.: { 'a' : {'A': 3, 'B': 4}, 'b' : [1,2,3], 'c' : 'hello world', 'd' : url('http://example.com/my_cool_parameter_set') }

This is largely the JSON (www.json.org) format, but with extra keywords in the Namespace such as ParameterRange, GammaDist, etc.

Python also supports specifying dictionaries as follows:

dict(x=1,y=2)

But usage of such un-JSON-ly idioms should likely be discouraged...

__cmp__ = <slot wrapper '__cmp__' of 'dict' objects>

__contains__ = <method '__contains__' of 'dict' objects>

__delitem__ = <slot wrapper '__delitem__' of 'dict' objects>

__eq__ = <slot wrapper '__eq__' of 'dict' objects>

__ge__ = <slot wrapper '__ge__' of 'dict' objects>

__gt__ = <slot wrapper '__gt__' of 'dict' objects>

__iter__ = <slot wrapper '__iter__' of 'dict' objects>

__le__ = <slot wrapper '__le__' of 'dict' objects>

__len__ = <slot wrapper '__len__' of 'dict' objects>

__lt__ = <slot wrapper '__lt__' of 'dict' objects>

__ne__ = <slot wrapper '__ne__' of 'dict' objects>

clear = <method 'clear' of 'dict' objects>

copy = <method 'copy' of 'dict' objects>

fromkeys = <built-in method fromkeys of type object at 0x220eb00>

get = <method 'get' of 'dict' objects>

has_key = <method 'has_key' of 'dict' objects>

items = <method 'items' of 'dict' objects>

iteritems = <method 'iteritems' of 'dict' objects>

iterkeys = <method 'iterkeys' of 'dict' objects>

itervalues = <method 'itervalues' of 'dict' objects>

keys = <method 'keys' of 'dict' objects>

non_parameter_attributes = ['_url', 'label', 'names', 'parameters', 'flat', 'flatten', 'non_parameter_attributes', 'row', 'rows', 'row_labels', 'column', 'columns', 'column_labels']

pop = <method 'pop' of 'dict' objects>

popitem = <method 'popitem' of 'dict' objects>

setdefault = <method 'setdefault' of 'dict' objects>

update = <method 'update' of 'dict' objects>

values = <method 'values' of 'dict' objects>


UniformDist

uniform distribution with min,max

__eq__(self, o)

__init__(self, min=0.0, max=1.0)

from_stats(self, vals, bias=0.0, expand=1.0)

next(self, n=1)