echidna package

Subpackages

Submodules

echidna.utilities module

Utilities module to include functions that may be useful throughout echidna.

class echidna.utilities.DispatchingFormatter(formatters, default_formatter)[source]

Dispatch formatter for logger and it’s sub logger.

Adapted from: https://stackoverflow.com/questions/1741972/
how-to-use-different-formatters-with-the-same-logging-handler-in-python.
Parameters:
  • formatters (dict) – Dictionary of named formatters
  • default_formatter (logging.Formatter) – Default formatter to use when no named formatter matches.
format(record)[source]

Format each record accordingly

Parameters:record (logging.LogRecord) – Log record to format.
Returns:logging.Formatter: Appropriate Formatter.
class echidna.utilities.Timer[source]

Useful timer class to show time elapsed performing a code block.

Examples

>>> With Timer() as t:
...     # block of code to time
>>> print ('Code executed in %.03f sec.' % t._interval)
__enter__()[source]
Variables:_start (float) – start time of code block
Returns:Timer: class instance
__exit__(*args)[source]
Variables:
  • _end (float) – end time of code block
  • _interval (float) – time elapsed during code block
echidna.utilities.get_array_errors(array, lin_err=0.01, frac_err=None, log=False, log10=False)[source]
echidna.utilities.start_logging(short_name=False, script_name=True)[source]

Function to initialise logging output.

Adapted from: https://docs.python.org/2/howto/logging-cookbook.html# logging-to-multiple-destinations

Parameters:
  • short_name (bool, optional) – If true the log name is always ‘echidna.log’
  • script_name (string, optional) – Name of script to add to log filename
Returns:

logging.Logger: Logger to use in script.

Module contents