def __fillStatistics__(self, _statistics_base_classes): model = self.__table__.model() model.removeRows(0, model.rowCount()) self.__statistics_classes__ = [] for base_class in _statistics_base_classes: for subclass in get_subclasses(base_class): self.__statistics_classes__.append(subclass) #sort alphabetically cmp_stat = lambda x, y: cmp(x.__name__, y.__name__) self.__statistics_classes__ = sorted(self.__statistics_classes__, cmp_stat) for statistic_class in self.__statistics_classes__: check_column = QStandardItem('%s' % statistic_class.__name__) check_column.setCheckState(Qt.Unchecked) check_column.setCheckable(True) description_column = QStandardItem(str(statistic_class().description)) # @IgnorePep8 value_column = QStandardItem('') model.appendRow([check_column, description_column, value_column])
def __fillStatistics__(self, _statistics_base_classes): model = self.__table__.model() model.removeRows(0, model.rowCount()) self.__statistics_classes__ = [] for base_class in _statistics_base_classes: for subclass in get_subclasses(base_class): self.__statistics_classes__.append(subclass) #sort alphabetically cmp_stat = lambda x, y: cmp(x.__name__, y.__name__) self.__statistics_classes__ = sorted(self.__statistics_classes__, cmp_stat) for statistic_class in self.__statistics_classes__: check_column = QStandardItem('%s' % statistic_class.__name__) check_column.setCheckState(Qt.Unchecked) check_column.setCheckable(True) description_column = QStandardItem( str(statistic_class().description)) # @IgnorePep8 value_column = QStandardItem('') model.appendRow([check_column, description_column, value_column])
def get_unit_by_class_name(_class_name): """ returns unit object based on unit class name """ if _class_name: for subclass_unit in get_subclasses(__Unit__): if subclass_unit.__name__.endswith(_class_name): for unit_type in __UNITS_TYPE_MAP__: for unit in __UNITS_TYPE_MAP__.get(unit_type): if isinstance(unit, subclass_unit): return unit return NoneUnit
def calculate_tachogram_statistics(**data): """ function to calculate all statistics associated with tachogram plots """ outcomes = {} descriptions = {} for tachogram_statistic_class in get_subclasses(TachogramStatistic): tachogram_statistic = tachogram_statistic_class(**data) #remove TachogramStatistic label name = tachogram_statistic_class.__name__ descriptions[name] = tachogram_statistic.description outcomes[name] = tachogram_statistic.compute() return (outcomes, descriptions, )
def calculate_tachogram_statistics(**data): """ function to calculate all statistics associated with tachogram plots """ outcomes = {} descriptions = {} for tachogram_statistic_class in get_subclasses(TachogramStatistic): tachogram_statistic = tachogram_statistic_class(**data) #remove TachogramStatistic label name = tachogram_statistic_class.__name__ descriptions[name] = tachogram_statistic.description outcomes[name] = tachogram_statistic.compute() return ( outcomes, descriptions, )