aixd.data.utils_data.reformat_list_to_dict

aixd.data.utils_data.reformat_list_to_dict(nested_list: List[List], dataobjects: List[DataObject]) Dict[source]

Reformats data formatted as a nested list into a dictionary. Each item in the list corresponds to one sample and contains a flattened list of values (no further sub-lists). The purpose of this method is to associate the data with names and collate into their original dimensions. The information about the original dimensions and names of the data objects is drawn from the given list of dataobjects. The order of the provided data objects must match the data in the nested list.

Parameters:
  • nested_list (List[List]) – List of lists, containing data.

  • dataobjects (List[DataObject]) – List of data objects from which names and dimensions will be recovered.

Returns:

Dict – Data in form of a dictionary.

Examples

>>> from aixd.data.data_objects import DataInt
>>> a = DataInt(name = "a", dim=2)
>>> b = DataInt(name = "b", dim=1)
>>> c = DataInt(name = "c", dim=1)
>>> nested_list = [[1,1, 2, 3], [7,7,8,9]]
>>> reformat_list_to_dict(nested_list, [a,b,c])
{'a': [[1, 1], [7, 7]], 'b': [2, 8], 'c': [3, 9]}