core Package
core Package
-
class
LocMgr[source] Bases:
object-
_locations= {'rootdir': '/home/docs/checkouts/readthedocs.org/user_builds/morphforge/envs/latest/local/lib/python2.7/site-packages'}
-
classmethod
ensure_dir_exists(dir_location)[source] Helper function that will make directories if they don’t exist.
Useful for temporary locations
-
classmethod
get_bin_path()[source]
-
classmethod
get_default_channel_summary_output_dir()[source]
-
classmethod
get_default_mod_builddir()[source]
-
classmethod
get_default_mod_outdir()[source]
-
classmethod
get_default_output_dir()[source]
-
classmethod
get_default_summary_output_dir()[source]
-
classmethod
get_log_path()[source]
-
classmethod
get_path_from_rcfile(subsection, default)[source]
-
classmethod
get_ply_parsetab_path(subdir)[source]
-
classmethod
get_root_path()[source]
-
classmethod
get_simulation_results_tmp_dir()[source]
-
classmethod
get_simulation_tmp_dir()[source]
-
classmethod
get_temporary_filename(suffix='', filedirectory=None)[source]
-
classmethod
get_test_mods_path()[source]
-
classmethod
get_test_srcs_path()[source]
-
classmethod
get_tmp_path()[source]
-
classmethod
validate_exists(cell_location)[source] Helper function to ensure that returned path actually does exist
-
-
class
LogMgr[source] Bases:
object-
_initialised_state= 'Ready'
-
classmethod
_is_logging_active_and_ready()[source]
-
classmethod
_pyfile_to_modulename(filename)[source]
-
classmethod
config()[source]
-
classmethod
create_logger(log_name)[source]
-
classmethod
debug(msg)[source]
-
classmethod
get_caller()[source]
-
classmethod
get_logger()[source]
-
classmethod
info(msg)[source]
-
classmethod
info_from_logger(msg)[source]
-
loggers= {'morphforge.core.logmgr': <logging.Logger object at 0x7f0ab1dbd290>, 'DISABLEDLOGGING': <logging.Logger object at 0x7f0ab1dbd4d0>}
-
classmethod
warning(msg)[source]
-
-
class
SettingsMgr[source] Bases:
objectDoc String for Settings Manager
-
_clearTempAllAt_start= True
-
_logging= False
-
classmethod
get_ply_yacc_debug_flag()[source]
-
classmethod
is_logging()[source]
-
classmethod
simulator_is_verbose()[source]
-
-
class
RCMgr[source] Bases:
object-
_rc_config_parser= None
-
_rc_filename= '/home/docs/.morphforgerc'
-
classmethod
get(section, option)[source]
-
classmethod
get_config()[source]
-
classmethod
has(section, option)[source]
-
classmethod
has_config()[source]
-
-
merge_dictionaries(dictionaries)[source] Merge a sequence of dictionaries safely.
This function merges dictionaries together, but ensures that there are not same keys which point to different values. That is, merge_dictionaries({‘alpha’:True}, {‘alpha’:True}) is OK, but merge_dictionaries({‘alpha’:True}, {‘alpha’:False}) will raise an exception
-
class
FileIO[source] Bases:
objectA collection of file utility functions
-
classmethod
append_to_file(txt, filename, file_expected=True)[source] Appends text to an existing file.
By default the file is expected to already exist, otherwise an IOError exception be thrown. This can be overridden with the file_expected parameter. Returns filename
-
classmethod
get_hash_md5(filename)[source] Returns the md5 checksum of a file.
This function should not be used for large files, since it loads the entire file into memory.
-
classmethod
read_from_file(filename)[source] Reads text from a file
-
classmethod
write_to_file(txt, filename=None, filedirectory=None, suffix=None)[source] Writes text to a file This function will overwrite an existing file. If no filename is given, a filename will be invented, using LocMgr.get_temporary_filename(). The name of the file written to will be returned.
-
classmethod
-
class
SeqUtils[source] Bases:
objectA collection of utility functions for working with sequences
-
classmethod
expect_single(l)[source] Expects a sequence containing a single object and returns it.
If 0 or more than 1 objects are found, it raises an error.
-
classmethod
filter_expect_single(seq, filter_func)[source] Filters a sequence according to the predicate filter_func, then expects a single item to remain, which it returns. If 0 or more than 1 objects are found, it raises an error.
-
classmethod
filter_with_prob(lst, p)[source] Returns a copy of the sequence, in which each item in the original has a fixed probability of being in the new sequence.
-
classmethod
flatten(seq, flatten_types=(<type 'tuple'>, <type 'list'>))[source] ‘Flattens’ a sequence recursively.
The objects types to flatten are specified by the flatten_types parameter, which must by a tuple of classes. By default it flattens lists and tuples.
-
classmethod
max_with_unique_check(collection, key)[source] Return the maximum from a sequence, based on a key, but verify that there is a unique maximum.
This is designed to be used when the key generates integers.
-
classmethod
-
class
StrUtils[source] Bases:
objectA collection of string utility functions
-
classmethod
get_hash_md5(s)[source] Returns the md5 digest hash of a string
-
classmethod
strip_comments_and_blank_lines(text, cmt_sym='#')[source] Removes comments and blank lines from block of text
-
classmethod
-
check_cstyle_varname(name)[source] Check a string conforms to a C-style variable name.
-
is_iterable(f)[source] Returns True if an object can be iterated over by using iter(obj)
-
class
ObjectLabeller[source] Bases:
objectProvides names for internal use for annoymous objects
Often, we need to automatically generate names for objects. For example, a user might not nessesarily provide names for all cells in simulations, but the simulator will expect variable names to refer to them. This class provides methods to create new names of objects, based on their type.
-
classmethod
get_next_count_for_type(obj)[source]
-
classmethod
get_next_unamed_object_name(obj_type, prefix=None, num_fmt_string=None)[source] Returns the next ‘anonymous’ name for an object of ‘obj_type’.
-
objectcount= {}
-
classmethod
-
Join(a, *p) Join two or more pathname components, inserting ‘/’ as needed. If any component is an absolute path, all previous path components will be discarded. An empty last part will result in a path that ends with a separator.
-
class
PluginDict[source] Bases:
objectBasic component for making features of morphforge ‘pluggable’.
This class simply wraps a dictionary, and exposes some methods to make the intention of code clearer.
-
__init__()[source]
-
__iter__()[source]
-
get_plugin(plugin_name)[source] Returns a previously registered plugin
-
keys()[source]
-
register_plugin(plugin_name, plugin)[source] Registers a plugin
-
-
class
MFRandom[source] Bases:
objectA class to centralise random numbers.
This is centralised so that a seed can be set in a single place in order to make simulations repeatable. This is particularly relevant in the case of NEURON simulations, which are saved and spawned in another process.
-
classmethod
_reseed()[source]
-
_seed= None
-
classmethod
get_seed()[source] Returns the current seed used
-
classmethod
seed(seed)[source] Seed the random number generator
This method simply calls ‘random.seed()’ and ‘numpy.random.seed()’
-
classmethod
mfrandom Module
-
class
MFRandom[source] Bases:
objectA class to centralise random numbers.
This is centralised so that a seed can be set in a single place in order to make simulations repeatable. This is particularly relevant in the case of NEURON simulations, which are saved and spawned in another process.
-
classmethod
_reseed()[source]
-
_seed= None
-
classmethod
get_seed()[source] Returns the current seed used
-
classmethod
seed(seed)[source] Seed the random number generator
This method simply calls ‘random.seed()’ and ‘numpy.random.seed()’
-
classmethod
misc Module
A collection of utility functions. Often these are not the most efficient implementations, especially when dealing with large files, but for most files morphforge has to deal with, they work fine and make code more readable.
-
class
FileIO[source] Bases:
objectA collection of file utility functions
-
classmethod
append_to_file(txt, filename, file_expected=True)[source] Appends text to an existing file.
By default the file is expected to already exist, otherwise an IOError exception be thrown. This can be overridden with the file_expected parameter. Returns filename
-
classmethod
get_hash_md5(filename)[source] Returns the md5 checksum of a file.
This function should not be used for large files, since it loads the entire file into memory.
-
classmethod
read_from_file(filename)[source] Reads text from a file
-
classmethod
write_to_file(txt, filename=None, filedirectory=None, suffix=None)[source] Writes text to a file This function will overwrite an existing file. If no filename is given, a filename will be invented, using LocMgr.get_temporary_filename(). The name of the file written to will be returned.
-
classmethod
-
class
ParameterSweepValues(values)[source] Bases:
object-
__getitem__(index)[source]
-
__init__(values)[source]
-
__iter__()[source]
-
__len__()[source]
-
_short_iter()[source]
-
-
class
SeqUtils[source] Bases:
objectA collection of utility functions for working with sequences
-
classmethod
expect_single(l)[source] Expects a sequence containing a single object and returns it.
If 0 or more than 1 objects are found, it raises an error.
-
classmethod
filter_expect_single(seq, filter_func)[source] Filters a sequence according to the predicate filter_func, then expects a single item to remain, which it returns. If 0 or more than 1 objects are found, it raises an error.
-
classmethod
filter_with_prob(lst, p)[source] Returns a copy of the sequence, in which each item in the original has a fixed probability of being in the new sequence.
-
classmethod
flatten(seq, flatten_types=(<type 'tuple'>, <type 'list'>))[source] ‘Flattens’ a sequence recursively.
The objects types to flatten are specified by the flatten_types parameter, which must by a tuple of classes. By default it flattens lists and tuples.
-
classmethod
max_with_unique_check(collection, key)[source] Return the maximum from a sequence, based on a key, but verify that there is a unique maximum.
This is designed to be used when the key generates integers.
-
classmethod
-
class
StrUtils[source] Bases:
objectA collection of string utility functions
-
classmethod
get_hash_md5(s)[source] Returns the md5 digest hash of a string
-
classmethod
strip_comments_and_blank_lines(text, cmt_sym='#')[source] Removes comments and blank lines from block of text
-
classmethod
-
class
benchmark(name)[source] Bases:
object-
__enter__()[source]
-
__exit__(ty, val, tb)[source]
-
__init__(name)[source]
-
-
check_cstyle_varname(name)[source] Check a string conforms to a C-style variable name.
-
find_files_recursively(directory, pattern)[source] Recursive ‘glob’ for files.
This function walks over a directory looking for filenames matching a certain pattern
-
is_float(f)[source] Deprecated
-
is_int(f)[source] Deprecated
-
is_iterable(f)[source] Returns True if an object can be iterated over by using iter(obj)
-
merge_dictionaries(dictionaries)[source] Merge a sequence of dictionaries safely.
This function merges dictionaries together, but ensures that there are not same keys which point to different values. That is, merge_dictionaries({‘alpha’:True}, {‘alpha’:True}) is OK, but merge_dictionaries({‘alpha’:True}, {‘alpha’:False}) will raise an exception
mockcontrol Module
-
class
MockControl[source] Bases:
object-
is_mock_simulation= None
-
monkey_patching Module
objectnumberer Module
-
class
ObjectLabeller[source] Bases:
objectProvides names for internal use for annoymous objects
Often, we need to automatically generate names for objects. For example, a user might not nessesarily provide names for all cells in simulations, but the simulator will expect variable names to refer to them. This class provides methods to create new names of objects, based on their type.
-
classmethod
get_next_count_for_type(obj)[source]
-
classmethod
get_next_unamed_object_name(obj_type, prefix=None, num_fmt_string=None)[source] Returns the next ‘anonymous’ name for an object of ‘obj_type’.
-
objectcount= {}
-
classmethod
plugindict Module
-
class
PluginDict[source] Bases:
objectBasic component for making features of morphforge ‘pluggable’.
This class simply wraps a dictionary, and exposes some methods to make the intention of code clearer.
-
__init__()[source]
-
__iter__()[source]
-
get_plugin(plugin_name)[source] Returns a previously registered plugin
-
keys()[source]
-
register_plugin(plugin_name, plugin)[source] Registers a plugin
-