gotran.common package¶
Submodules¶
gotran.common.dicts module¶
-
class
gotran.common.dicts.adict(**kwargs)[source]¶ Bases:
dictA dictionary with attribute-style access. It maps attribute access to the real dictionary.
-
class
gotran.common.dicts.odict(iterable=None)[source]¶ Bases:
dictA simple ordered dict
-
pop(k[, d]) → v, remove specified key and return the corresponding value.[source]¶ If key is not found, d is returned if given, otherwise KeyError is raised
-
popitem() → (k, v), remove and return some (key, value) pair as a[source]¶ 2-tuple; but raise KeyError if D is empty.
-
gotran.common.disk module¶
-
gotran.common.disk.load(basename, latest_timestamp=False, collect=False)[source]¶ Load data using cPickle
@type basename : str @param basename : The name of the file where the data will be loaded from, ‘.cpickle’ will be appended to the file name if not provided @type latest_timestamp : bool @param latest_timestamp : If true return the data from latest version of saved data with the same basename @type collect : bool @param collect : If True collect all data with the same basename and the same parameters
gotran.common.options module¶
Module contents¶
-
class
gotran.common.Logger(name)[source]¶ Bases:
object-
pop_log_level()[source]¶ Pop log level from the level stack, reverting to before the last push_level.
-
-
exception
gotran.common.GotranException[source]¶ Bases:
RuntimeErrorBase class for ModelParameters exceptions
-
gotran.common.ClassType¶ alias of
builtins.type
-
gotran.common.reduce(function, sequence[, initial]) → value¶ Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the sequence is empty.
-
gotran.common.VALUE_JUST(s, *args, **kwargs)¶
-
gotran.common.value_formatter(value, width=0)[source]¶ Return a formated string of a value
Parameters: - value (any) – The value which is formatted
- width (int) – A min str length value
-
class
gotran.common.Range(ge=None, le=None, gt=None, lt=None)[source]¶ Bases:
objectA simple class for helping checking a given value is within a certain range
-
format(value, width=0)[source]¶ Return a formated range check of the value
Parameters: - value (scalar) – A value to be used in checking range
- width (int) – A min str length value
-
-
gotran.common.format_time(time)[source]¶ Return a formated version of the time argument
Parameters: time (float) – Time given in sections
-
gotran.common.is_iterable(obj)[source]¶ Test for iterable
Parameters: obj (any) – Object which is beeing tested
-
gotran.common.check_arg(arg, argtypes, num=-1, context=None, itemtypes=None, ge=None, le=None, gt=None, lt=None)[source]¶ Type check for positional arguments
Parameters: - arg (any) – The argument to be checked
- argtypes (type, tuple) – The type of which arg should be
- num (int (optional)) – The argument positional number
- context (type, function/method (optional)) – The context of the check. If context is a class the check is assumed to be during creation. If a function/method the contex is assumed to be a call to that function/method
- itemtypes (type (optional)) – If given argtypes must be a tuple or list and itemtypes forces each item to be a certain type
- ge (scalar (optional)) – Greater than or equal, range control of argument
- le (scalar (optional)) – Lesser than or equal, range control of argument
- gt (scalar (optional)) – Greater than, range control of argument
- lt (scalar (optional)) – Lesser than, range control of argument
-
gotran.common.check_kwarg(kwarg, name, argtypes, context=None, itemtypes=None, ge=None, le=None, gt=None, lt=None)[source]¶ Type check for keyword arguments
Parameters: - kwarg (any) – The keyword argument to be checked
- name (str) – The name of the keyword argument
- argtypes (type, tuple) – The type of which arg should be
- context (type, function/method (optional)) – The context of the check. If context is a class the check is assumed to be during creation. If a function/method the contex is assumed to be a call to that function/method
- itemtypes (type (optional)) – If given argtypes must be a tuple or list and itemtypes forces each item to be a certain type
- ge (scalar (optional)) – Greater than or equal, range control of argument
- le (scalar (optional)) – Lesser than or equal, range control of argument
- gt (scalar (optional)) – Greater than, range control of argument
- lt (scalar (optional)) – Lesser than, range control of argument
-
gotran.common.deprecated(func)[source]¶ This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used.
-
class
gotran.common.adict(**kwargs)[source]¶ Bases:
dictA dictionary with attribute-style access. It maps attribute access to the real dictionary.
-
class
gotran.common.odict(iterable=None)[source]¶ Bases:
dictA simple ordered dict
-
pop(k[, d]) → v, remove specified key and return the corresponding value.[source]¶ If key is not found, d is returned if given, otherwise KeyError is raised
-
popitem() → (k, v), remove and return some (key, value) pair as a[source]¶ 2-tuple; but raise KeyError if D is empty.
-
-
gotran.common.load(basename, latest_timestamp=False, collect=False)[source]¶ Load data using cPickle
@type basename : str @param basename : The name of the file where the data will be loaded from, ‘.cpickle’ will be appended to the file name if not provided @type latest_timestamp : bool @param latest_timestamp : If true return the data from latest version of saved data with the same basename @type collect : bool @param collect : If True collect all data with the same basename and the same parameters