Utilities

Useful helper functions for running the cli.

mdacli.utils.convert_str_time(x, dt)[source]

Convert a string x into a frame number based on given dt.

If x does not contain any units its assumed to be a frame number already.

See split_time_unit().

Parameters:
  • x (str) – the input string

  • dt (float) – the time step in ps

Returns:

int – frame number

Raises:

ValueError – The input does not contain any units but is not an integer.

mdacli.utils.parse_callable_signature(callable_obj)[source]

Parse a callable signature to a convenient dictionary for CLI creation.

The parameters used in the CLI are a combination of the callable signature and the information in the callable docstring.

Parameters:

callable_obj (callable) – The callable object to inspect. Details of this object required for the creation of a CLI are added to the storage_dict.

Returns:

dict

mdacli.utils.parse_docs(klass)[source]

Parse classes docstrings to a convenient dictionary.

This parser is based on NumpyDocString format, yet it is not so strict. Combined docstrings from class main docstring and __init__ method.

Parameters:

klass (callable) – A klass object from which a DOCSTRING can be extracted.

Returns:

tuple (str, str, dict of dict)

  • One line summary description of the callable

  • Extended description of the callable

  • dictionary where keys are parameter names and subdictinary

    has keys “type” and “desc” for parameter type and description.

mdacli.utils.split_time_unit(s)[source]

Split time and units.

Follows the regex:: https://regex101.com/r/LZAbil/2

Returns:

tuple (float, str) – Value as float, units as str.

Raises:

IndexError – Tuple could not be found. This happens when a number is not present in the start of the string.