General utility functions (dqa.utils
)#
Utility functions for DQA
- class dqa.utils.Timer#
Methods
reset
()start
(key)stop
(key)- CLASSIFICATION = 'Classification'#
- LOAD_CSV = 'Loading CSV data'#
- SPLIT_DATA = 'Splitting data'#
- TOTAL = 'Total'#
- TRAIN_CLASSIFIER = 'Training classifier'#
- TRAIN_PIPELINE = 'Training pipeline'#
- static reset()#
- static start(key)#
- started = {}#
- static stop(key)#
- times = {}#
- dqa.utils.auto_convert(x: str) int | float | str #
Automatically converts a string into int or float. If it does not work, then the string will be returned. :param x: A string that possibly contains a number. :return: The number as int or float.
- dqa.utils.dict_to_df(input_dict)#
Converts a dictionary of arrays to a pandas data frame by first extending all entries to the maximum length. :param input_dict: Dictionary containing numpy arrays. :return: A dataframe containing the same data.
- dqa.utils.ensure_list(obj: Any) list #
Returns obj if it is already a list and [obj] otherwise.
- dqa.utils.ensure_list_or_none(obj: Any) list | None #
Returns obj if it is already a list or None and [obj] otherwise.
- dqa.utils.equal_general(a, b)#
Checks if a and b are equal. This especially applies to nested structures of lists and dictionaries of numpy arrays.
- dqa.utils.filename_without_ending(filename: str) str #
Returns the filename without the ending from an entire path.
- dqa.utils.get_class(class_name: str) type #
Returns a class from a given module.classname notion. :param class_name: module.classname :return: The type object referring to the class.
- dqa.utils.get_classes_of_module(module_name: str) List[type] #
Lists all classes in a specified module :param module_name: Name of the module. :return: List containing all classes.
- dqa.utils.in_out_names_list(input_name: str | List[str], output_name: str | List[str] | None = None)#
Converts input and output names into lists of equal length as it is used in tasks. :param input_name: The input names as a list or a single string. :param output_name: The output names as a list or a single string. :return: Tuple containing the resulting input and output name list.
- dqa.utils.init_logging(level=20, log_directory='.')#
Initializes basic logging functions. Results will be logged to a file and to the standard output.
- dqa.utils.is_float(val)#
- dqa.utils.is_int(val)#
- dqa.utils.isnan_extended(value)#
Checks if any of the entries in value are nan. The input can be of any type or an array with various types.