skbel.utils

This package contains utility methods that are used by the other packages in the library.

skbel.utils.utils

skbel.utils.utils.Function

alias of LambdaType

skbel.utils.utils.combinator(combi)[source]

Given an n-sized 1D array, generates all possible configurations.

Parameters:

combi – List of size n.

Returns:

List of combinations.

skbel.utils.utils.data_read(file: str = None, start: int = 0, end: int = None, step: int = None, delimiter: str = None)[source]

Reads data from a file. It needs to be a text file and the data needs to be separated by a space or tab (default) or by a delimiter specified by the user.

Parameters:
  • file – File path, such as ‘data.txt’.

  • start – Starting line, default is 0.

  • end – Ending line, default is None (last line).

  • step – Step, default is 1 (every line).

  • delimiter – Delimiter, default is None (space).

Returns:

Data contained in file. np.array if data can be converted to float, else list.

skbel.utils.utils.dirmaker(dird: str, erase: bool = False)[source]

Given a folder path, check if it exists, and if not, creates it.

Parameters:
  • dird – Directory path.

  • erase – Whether to delete existing folder or not.

skbel.utils.utils.flatten_array(arr: array) array[source]

Flattens a numpy array.

Parameters:

arr – Numpy array.

Returns:

Flattened array.

skbel.utils.utils.folder_reset(folder: str, exceptions: list = None)[source]

Deletes files in folder.

Parameters:
  • folder – Folder path.

  • exceptions – List of files to keep.