Source code for tmtk.highdim.HighDim

from ..utils import path_converter, md5, Mappings, PathError
from tmtk.utils.CPrint import CPrint


[docs]class HighDim: """ Container class for all High Dimensional data types. :param params_list: contains a list with Params objects. """ def __init__(self, params_list=None, parent=None): assert type(params_list) == list, \ 'Expected list with annotation params, but got {}.'.format(type(params_list)) for p in params_list: new_instance = Mappings.get_highdim(p.datatype) try: self.__dict__[str(p)] = new_instance(p, parent=parent) except PathError: continue
[docs] def validate_all(self, verbosity=3): for key, obj in self.__dict__.items(): if hasattr(obj, 'validate'): obj.validate(verbosity=verbosity)
[docs] def update_high_dim_paths(self, high_dim_paths): """ Update sample mapping if path has been changed. :param high_dim_paths: dictionary with paths and old concept paths. """ changed_dict = {k: path for k, path in high_dim_paths.items() if md5(path_converter(path)) != k} if changed_dict: CPrint.okay('Found ({}) changed concept paths.'.format(len(changed_dict))) else: CPrint.info('No changes found in any HighDim paths.') return for ss in self.high_dim_nodes: ss.sample_mapping.update_concept_paths(changed_dict)
@property def high_dim_nodes(self): return [x for k, x in self.__dict__.items() if hasattr(x, 'sample_mapping')]