Helpers module¶
- class bsb.helpers.ConfigurableClass[source]¶
A class that can be configured.
- cast_config()[source]¶
Casts/validates values imported onto this object from configuration files to their final form. The casts dictionary should contain the key of the attribute and a function that takes a value as only argument. This dictionary will be used to cast the attributes when cast_config is called.
- class bsb.helpers.DistributionConfiguration[source]¶
Cast a configuration node into a scipy.stats distribution.
- fallback¶
alias of
float
- bsb.helpers.assert_attr_array(section, attr, section_name)[source]¶
Asserts that an attribute exists on a dictionary or object, and that it is an array.
- Parameters
section (dict, object) – Dictionary or object that needs to contain the attribute.
attr (string) – Attribute name.
section_name (string) – Name of the section to print out the location of the missing attribute.
- bsb.helpers.assert_attr_in(section, attr, values, section_name)[source]¶
Assert that the attribute is present in the section dictionary and that its value is included in the given array.
- bsb.helpers.continuity_hop(iterator)[source]¶
Hop over a continuity list in steps of 2, returning the start & count pairs.
- bsb.helpers.continuity_list(iterable, step=1)[source]¶
Return a compacted notation of a list of nearly continuous numbers.
The
iterable
will be iterated and chains of continuous numbers will be determined. Each chain will then be added to the output format as a starting number and count.Example:
[4,5,6,7,8,9,12]
==>[4,6,12,1]
- Parameters
iterable (iter) – The collection of elements to be compacted.
step –
iterable[i]
needs to be equal toiterable[i - 1] + step
for them to considered continuous.
- bsb.helpers.expand_continuity_list(iterable, step=1)[source]¶
Return the full set of items associated with the continuity list, as formatted by
helpers.continuity_list()
.