src.utils package

Submodules

src.utils.util module

Utility module for this project.

DependencyError

Exception intended for unmet external dependencies

file_parts

Similar to MATLAB's fileparts function shown here.

check_dependencies

Checks if the required dependencies are installed.

timeit

Timing (decorator) function to time the execution of a function.

exception src.utils.util.DependencyError[source]

Bases: Exception

Exception intended for unmet external dependencies

src.utils.util.check_dependencies(dependencies)[source]

Checks if the required dependencies are installed.

Parameters:

dependencies (Tuple[str]) – Tuple of required dependencies.

Raises:

DependencyError – If any of the dependencies are not installed.

Return type:

bool

Returns:

True if all dependencies are installed.

src.utils.util.file_parts(file)[source]

Similar to MATLAB’s fileparts function shown here.

Splits a full filename into:
  • file path

  • filename (no file path, no file extension)

  • file extension

Usage example:
>>> path_name, file_name, file_ext = file_parts('/Users/username/Desktop/file.txt')
>>> path_name
'/Users/username/Desktop'
>>> file_name
'file'
>>> file_ext
'.txt'
Parameters:

file (str) – Input file filename.

Returns:

  • file path

  • filename (no file path, no file extension)

  • file extension

Return type:

Tuple

src.utils.util.timeit(func)[source]

Timing (decorator) function to time the execution of a function.

Prints the execution time of the function.

Usage example:
>>> @timeit
... def main():
...     print("Hello, World!")
...
>>> main()
Begin: main
Hello, World!
End: main Execution time: 0.00 sec.
Parameters:

func (callable) – Function to be timed.

Return type:

callable

Returns:

Decorated function.

Module contents