<commit_before>#!/usr/bin/env python3

import numpy as np
import math
import sys, os
from pprint import pprint

def getTimeMax(datafiles):
    """
    Compute the maximum seconds used by the set of islands.
    """

    max_values = []

    for data in datafiles:
        max_values += [float(data[-1][1])]

    return round(max(max_values))

def createTimelines(timemax, datafiles):
    """
    Create the timelines.
    """

    timelines = [None]*N
    for i in range(N):
        timelines[i] = [None]*timemax

    for i in range(N):
        for line in datafiles[i]:
            time = math.floor(float(line[1]))
            timelines[i][time] = line[2:]
    return timelines

def getTimelineInfo(timeline):
    """
    Parse the info data provided by a timeline and return.
    """

    info = {}
    info['nb'], info['avg'], info['delta'], info['best'], info['input'], info['output'] = timeline[:6]
    info['probas'] = [ float(x) for x in timeline[6:6+N] ]
    info['input_proba'] = float(timeline[6+N])
    info['migrants'] = [ int(x) for x in timeline[6+N+1:] ]

    convertToInt = ['nb', 'input', 'output',]
    convertToFloat = ['avg', 'delta', 'best']

    for key in convertToInt: info[key] = int(info[key])
    for key in convertToFloat: info[key] = float(info[key])

    return info

def writeInfoToResult(info, newfile):
    """
    Write down info to the new result file.
    """<commit_msg>* putTogatherAsyncResult.py: timemax+1 is the new size of timelines<commit_after>#!/usr/bin/env python3

import numpy as np
import math
import sys, os
from pprint import pprint

def getTimeMax(datafiles):
    """
    Compute the maximum seconds used by the set of islands.
    """

    max_values = []

    for data in datafiles:
        max_values += [float(data[-1][1])]

    return round(max(max_values))

def createTimelines(timemax, datafiles):
    """
    Create the timelines.
    """

    timelines = [None]*N
    for i in range(N):
        timelines[i] = [None]*(timemax+1)

    for i in range(N):
        for line in datafiles[i]:
            time = math.floor(float(line[1]))
            timelines[i][time] = line[2:]
    return timelines

def getTimelineInfo(timeline):
    """
    Parse the info data provided by a timeline and return.
    """

    info = {}
    info['nb'], info['avg'], info['delta'], info['best'], info['input'], info['output'] = timeline[:6]
    info['probas'] = [ float(x) for x in timeline[6:6+N] ]
    info['input_proba'] = float(timeline[6+N])
    info['migrants'] = [ int(x) for x in timeline[6+N+1:] ]

    convertToInt = ['nb', 'input', 'output',]
    convertToFloat = ['avg', 'delta', 'best']

    for key in convertToInt: info[key] = int(info[key])
    for key in convertToFloat: info[key] = float(info[key])

    return info

def writeInfoToResult(info, newfile):
    """
    Write down info to the new result file.
    """
{'fraction_non_alphanumeric': 0.1534446764091858, 'fraction_numerical': 0.008350730688935281, 'mean_word_length': 3.0954415954415953, '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': '7465024', 'n_tokens_mistral': 980, 'n_tokens_neox': 949, 'n_words': 270}