예제 #1
0
 def extract_value(run_result):
     pos = None
     for i, column in enumerate(run_result.columns):
         if column.title == column_identifier:
             pos = i
             break
     if pos is None:
         sys.exit(f"CPU time missing for task {run_result.task_id}.")
     return util.to_decimal(run_result.values[pos])
예제 #2
0
def extract_time(column_title, time_name, run_result):
    pos = None
    for i, column in enumerate(run_result.columns):
        if column.title == column_title:
            pos = i
            break
    if pos is None:
        sys.exit(f"{time_name} time missing for task {run_result.task_id}.")
    return util.to_decimal(run_result.values[pos])
예제 #3
0
def _get_stats_of_number_column(values, categoryList, correct_only):
    valueList = [util.to_decimal(v) for v in values]
    assert len(valueList) == len(categoryList)

    valuesPerCategory = collections.defaultdict(list)
    for value, (category, status) in zip(valueList, categoryList):
        if status is None:
            continue
        valuesPerCategory[category, result.get_result_classification(status)].append(
            value
        )

    stats = ColumnStatistics()
    stats.total = StatValue.from_list(valueList)

    def create_stat_value_for(*keys):
        all_values_for_keys = list(
            itertools.chain.from_iterable(valuesPerCategory[key] for key in keys)
        )
        return StatValue.from_list(all_values_for_keys)

    stats.correct = create_stat_value_for(
        (result.CATEGORY_CORRECT, result.RESULT_CLASS_TRUE),
        (result.CATEGORY_CORRECT, result.RESULT_CLASS_FALSE),
    )
    stats.correct_true = create_stat_value_for(
        (result.CATEGORY_CORRECT, result.RESULT_CLASS_TRUE)
    )
    stats.correct_false = create_stat_value_for(
        (result.CATEGORY_CORRECT, result.RESULT_CLASS_FALSE)
    )
    stats.correct_unconfirmed = create_stat_value_for(
        (result.CATEGORY_CORRECT_UNCONFIRMED, result.RESULT_CLASS_TRUE),
        (result.CATEGORY_CORRECT_UNCONFIRMED, result.RESULT_CLASS_FALSE),
    )
    stats.correct_unconfirmed_true = create_stat_value_for(
        (result.CATEGORY_CORRECT_UNCONFIRMED, result.RESULT_CLASS_TRUE)
    )
    stats.correct_unconfirmed_false = create_stat_value_for(
        (result.CATEGORY_CORRECT_UNCONFIRMED, result.RESULT_CLASS_FALSE)
    )
    if not correct_only:
        stats.wrong = create_stat_value_for(
            (result.CATEGORY_WRONG, result.RESULT_CLASS_TRUE),
            (result.CATEGORY_WRONG, result.RESULT_CLASS_FALSE),
        )
        stats.wrong_true = create_stat_value_for(
            (result.CATEGORY_WRONG, result.RESULT_CLASS_TRUE)
        )
        stats.wrong_false = create_stat_value_for(
            (result.CATEGORY_WRONG, result.RESULT_CLASS_FALSE)
        )
    return stats
예제 #4
0
def add_local_summary_statistics(run_set_result, run_set_stats):
    """
    Fill in the "local" values of ColumnStatistics instances in result of
    get_stats_of_run_set
    """
    for column, column_stats in zip(run_set_result.columns, run_set_stats):
        if (column.is_numeric() and column.title in run_set_result.summary
                and run_set_result.summary[column.title] != ""):

            try:
                column_stats.local = StatValue(
                    util.to_decimal(run_set_result.summary[column.title]))
            except InvalidOperation:
                pass