<commit_before>import time
from datetime import timedelta
from pokemongo_bot.inventory import Pokemons

class Metrics(object):

    def __init__(self, bot):
        self.bot = bot
        self.start_time = time.time()
        self.dust = {'start': -1, 'latest': -1}
        self.xp = {'start': -1, 'latest': -1}
        self.distance = {'start': -1, 'latest': -1}
        self.encounters = {'start': -1, 'latest': -1}
        self.throws = {'start': -1, 'latest': -1}
        self.captures = {'start': -1, 'latest': -1}
        self.visits = {'start': -1, 'latest': -1}
        self.unique_mons = {'start': -1, 'latest': -1}
        self.evolutions = {'start': -1, 'latest': -1}

        self.releases = 0
        self.highest_cp = {'cp': 0, 'desc': ''}
        self.most_perfect = {'potential': 0, 'desc': ''}
        self.eggs = {'hatched': 0, 'next_hatching_km': 0}

        self.uniq_pokemons_caught = None
        self.uniq_pokemons_list = None

    def runtime(self):
        return timedelta(seconds=round(time.time() - self.start_time))

    def xp_earned(self):
        return self.xp['latest'] - self.xp['start']

    def xp_per_hour(self):
        return self.xp_earned()/(time.time() - self.start_time)*3600

    def distance_travelled(self):
        return self.distance['latest'] - self.distance['start']

    def num_encounters(self):
        return self.encounters['latest'] - self.encounters['start']

    def num_throws(self):
        return self.throws['latest'] - self.throws['start']

    def num_captures(self):
        return self.captures['latest'] - self.captures['start']

    def uniq_caught(self):
        # generate pokemon string 'Snorlax, Pikachu' from list of ids
        return ', '.join([Pokemons.name_for(pok_id) for pok_id in self.uniq_pokemons_caught]) or ''

    def captures_per_hour(self):
        """
        Returns an estimated number of pokemon caught per hour.
        :return: An estimated number of pokemon caught per hour.
        :rtype: float
        """
        return self.num_captures() / (time.time() - self.start_time) * 3600

    def num_visits(self):
        return self.visits['latest'] - self.visits['start']

    def num_new_mons(self):
        return self.unique_mons['latest'] - self.unique_mons['start']<commit_msg>fix 4706 (#4710)<commit_after>import time
from datetime import timedelta
from pokemongo_bot.inventory import Pokemons

class Metrics(object):

    def __init__(self, bot):
        self.bot = bot
        self.start_time = time.time()
        self.dust = {'start': -1, 'latest': -1}
        self.xp = {'start': -1, 'latest': -1}
        self.distance = {'start': -1, 'latest': -1}
        self.encounters = {'start': -1, 'latest': -1}
        self.throws = {'start': -1, 'latest': -1}
        self.captures = {'start': -1, 'latest': -1}
        self.visits = {'start': -1, 'latest': -1}
        self.unique_mons = {'start': -1, 'latest': -1}
        self.evolutions = {'start': -1, 'latest': -1}

        self.releases = 0
        self.highest_cp = {'cp': 0, 'desc': ''}
        self.most_perfect = {'potential': 0, 'desc': ''}
        self.eggs = {'hatched': 0, 'next_hatching_km': 0}

        self.uniq_pokemons_caught = None
        self.uniq_pokemons_list = None

    def runtime(self):
        return timedelta(seconds=round(time.time() - self.start_time))

    def xp_earned(self):
        return self.xp['latest'] - self.xp['start']

    def xp_per_hour(self):
        return self.xp_earned()/(time.time() - self.start_time)*3600

    def distance_travelled(self):
        return self.distance['latest'] - self.distance['start']

    def num_encounters(self):
        return self.encounters['latest'] - self.encounters['start']

    def num_throws(self):
        return self.throws['latest'] - self.throws['start']

    def num_captures(self):
        return self.captures['latest'] - self.captures['start']

    def uniq_caught(self):
        # generate pokemon string 'Snorlax, Pikachu' from list of ids
        return ', '.join([Pokemons.name_for(pok_id) for pok_id in self.uniq_pokemons_caught]) if self.uniq_pokemons_caught else ''

    def captures_per_hour(self):
        """
        Returns an estimated number of pokemon caught per hour.
        :return: An estimated number of pokemon caught per hour.
        :rtype: float
        """
        return self.num_captures() / (time.time() - self.start_time) * 3600

    def num_visits(self):
        return self.visits['latest'] - self.visits['start']

    def num_new_mons(self):
        return self.unique_mons['latest'] - self.unique_mons['start']
{'fraction_non_alphanumeric': 0.1542483660130719, 'fraction_numerical': 0.015250544662309368, 'mean_word_length': 2.690514469453376, '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': '3794530', 'n_tokens_mistral': 1590, 'n_tokens_neox': 1510, 'n_words': 349}