<commit_before>import collections


def correct_champions(champions):
    for champion in champions:
        for ability in champion.abilities:
            correct_ability(ability)


ABILITY_CORRECTIONS = {
    # Ahri
    'Fox-Fire': {
        # @f1 shows maximum damage to a single target
        # Each fox-fire after the first does 30% damage
        # So if three hit a single target total is 160% damage
        '@f1@': lambda x: float(int(x.tooltip_values['@Effect1Amount@'] * 1.6)),
        'levels': {

        }
    },
}


def correct_ability(ability):
    def apply_correction(key, correction, level):
        if isinstance(correction, collections.Callable):
            correction = correction(level)
        level.tooltip_values[key] = correction

    correction = ABILITY_CORRECTIONS.get(ability.name, None)
    if correction is not None:
        for key, value in correction.items():
            if key == 'levels':
                # Corrections to individual levels
                # TODO: Refactor
                for level in value:
                    for i, (key, value) in enumerate(level.items()):
                        apply_correction(key, value, ability.levels[i])
            else:
                # Apply to all levels
                for level in ability.levels:
                    apply_correction(key, value, level)<commit_msg>Remove correction 'levels' support.<commit_after>import collections
import warnings


def correct_champions(champions):
    for champion in champions:
        for ability in champion.abilities:
            correct_ability(ability)


ABILITY_CORRECTIONS = {
    # Ahri
    'Fox-Fire': {
        # @f1 shows maximum damage to a single target
        # Each fox-fire after the first does 30% damage
        # So if three hit a single target total is 160% damage
        '@f1@': lambda x: float(int(x.tooltip_values['@Effect1Amount@'] * 1.6)),
        'levels': {

        }
    },
}


def correct_ability(ability):
    def apply_correction(key, correction, level):
        if isinstance(correction, collections.Callable):
            correction = correction(level)
        level.tooltip_values[key] = correction

    correction = ABILITY_CORRECTIONS.get(ability.name, None)
    if correction is not None:
        for key, value in correction.items():
            if key not in ability.tooltip:
                warnings.warn('Ability %s has unused correction %s.' %
                              (ability, key))
            # Apply to all levels
            for level in ability.levels:
                apply_correction(key, value, level)
{'fraction_non_alphanumeric': 0.08870034708831469, 'fraction_numerical': 0.007713073659853451, 'mean_word_length': 2.1557177615571774, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5348183', 'n_tokens_mistral': 720, 'n_tokens_neox': 672, 'n_words': 212}