Basic Functions

Various

Ver. 1.7.3 (2021-12-07)

This module provides various classes with elementry functionalities for reuse in higher level classes. For example: logging, load/save, timer, …

class mlpro.bf.various.Loadable

Bases: object

This abstract class adds the ability to be loadable to inherited classes.

static load(p_path, p_filename)

Loads content from the given path and file name. If file does not exist, it returns None.

Parameters
  • file (p_path Path that contains the) –

  • name (p_filename File) –

Returns

A loaded object, if file content was loaded successfully. None otherwise.

class mlpro.bf.various.Saveable

Bases: object

This abstract class adds the ability to be saveable to inherited classes. The filename can be generated internally by implementing the method get_filename() or provided from outside otherwise.

C_SUFFIX = '.pkl'
generate_filename()

To be redefined in case of use of internal generated file names.

Returns

Returns an internal unique filename.

save(p_path, p_filename=None) bool

Saves content to the given path and file name. If file name is None, a unique file name will be generated by calling method generate_filename(). If it returns False then the saving method is failed.

Parameters
  • saved (p_path Path where file will be) –

  • name (p_filename File) –

Returns

True, if file content was saved successfully. False otherwise.

class mlpro.bf.various.LoadSave

Bases: mlpro.bf.various.Loadable, mlpro.bf.various.Saveable

This abstract class adds the ability to be loadable and saveable to inherited classes. The filename can be generated internally by implementing the method generate_filename() or provided from outside otherwise. See classes Loadable and Saveable for further information.

class mlpro.bf.various.Log(p_logging=True)

Bases: object

This class adds elementry log functionality to inherited classes.

C_TYPE = '????'
C_NAME = '????'
C_LOG_TYPE_I = 'I'
C_LOG_TYPE_W = 'W'
C_LOG_TYPE_E = 'E'
C_LOG_TYPE_S = 'S'
C_LOG_TYPES = ['I', 'W', 'E', 'S']
C_COL_WARNING = '\x1b[93m'
C_COL_ERROR = '\x1b[91m'
C_COL_SUCCESS = '\x1b[32m'
C_COL_RESET = '\x1b[0m'
C_LOG_ALL = True
C_LOG_NOTHING = False
C_LOG_WE = 'W'
C_LOG_E = 'E'
C_LOG_LEVELS = [True, False, 'W', 'E']
switch_logging(p_logging)

Switches log functionality on/off.

Parameters

level (p_logging Log) –

log(p_type, *p_args)

Writes log line to standard output in format: yyyy-mm-dd hh:mm:ss.mmmmmm [p_type C_TYPE C_NAME]: [p_args]

Parameters
  • entry (p_type type of log) –

  • informations (p_args log) –

Returns

Nothing

class mlpro.bf.various.Timer(p_mode, p_lap_duration: datetime.timedelta, p_lap_limit=999999)

Bases: object

Timer class in two time modes (real/virtual) and with simple lap management.

C_MODE_REAL = 0
C_MODE_VIRTUAL = 1
C_LAP_LIMIT = 999999
reset() None

Resets timer.

Returns

Nothing

get_time() datetime.timedelta
get_lap_time() datetime.timedelta
get_lap_id()
add_time(p_delta: datetime.timedelta)
finish_lap() bool

Finishes the current lap. In timer mode C_MODE_REAL the remaining time until the end of the lap will be paused.

Returns

True, if the remaining time to the next lap was positive. False, if the timer timed out.

class mlpro.bf.various.TStamp(p_tstamp: Optional[datetime.timedelta] = None)

Bases: object

This class provides elementry time stamp functionality for inherited classes.

get_tstamp() datetime.timedelta
set_tstamp(p_tstamp: datetime.timedelta)
class mlpro.bf.various.ScientificObject

Bases: object

This class provides elementary functionality for storing a scientific reference.

C_SCIREF_TYPE_NONE = None
C_SCIREF_TYPE_ARTICLE = 'Journal Article'
C_SCIREF_TYPE_BOOK = 'Book'
C_SCIREF_TYPE_ONLINE = 'Online'
C_SCIREF_TYPE_PROCEEDINGS = 'Proceedings'
C_SCIREF_TYPE_TECHREPORT = 'Technical Report'
C_SCIREF_TYPE_UNPUBLISHED = 'Unpublished'
C_SCIREF_TYPE = None
C_SCIREF_AUTHOR = None
C_SCIREF_TITLE = None
C_SCIREF_JOURNAL = None
C_SCIREF_ABSTRACT = None
C_SCIREF_VOLUME = None
C_SCIREF_NUMBER = None
C_SCIREF_PAGES = None
C_SCIREF_YEAR = None
C_SCIREF_MONTH = None
C_SCIREF_DAY = None
C_SCIREF_DOI = None
C_SCIREF_KEYWORDS = None
C_SCIREF_ISBN = None
C_SCIREF_SERIES = None
C_SCIREF_PUBLISHER = None
C_SCIREF_CITY = None
C_SCIREF_COUNTRY = None
C_SCIREF_URL = None
C_SCIREF_CHAPTER = None
C_SCIREF_BOOKTITLE = None
C_SCIREF_INSTITUTION = None
C_SCIREF_CONFERENCE = None
C_SCIREF_NOTES = None
C_SCIREF_EDITOR = None

Mathematics

../../../_images/MLPro-BF-Math_class_diagram.png

Data Management

Data Plotting

Machine Learning

../../../_images/MLPro-BF-ML_class_diagram.png

Exceptions

Ver. 1.0.2 (2021-12-12)

This module provides exception classes.

exception mlpro.bf.exceptions.ParamError

Bases: Exception

To be raised on a parameter error…

exception mlpro.bf.exceptions.ImplementationError

Bases: Exception

To be raised on an implementation error in a child class of MLPro…

exception mlpro.bf.exceptions.Error

Bases: Exception

To be raised on an error…