<commit_before># coding=utf-8
import argparse
import errno
import os
import time
# from ..classes import load_simulation
import subprocess

import numpy as np


def config_filename(run_name, category_name=None, version_number=None):
    """
    Prepares config filename for saving.

    Parameters
    ----------
    run_name : str

    category_name : str

    version_number : int


    Examples
    ----------
    >>> config_filename("run")
    'data_analysis/run/run.hdf5'
    >>> config_filename("run", "simulation_type")
    'data_analysis/simulation_type/run/run.hdf5'
    >>> config_filename("run", "simulation_type", 1)
    'data_analysis/simulation_type/v1/run/run.hdf5'

    Returns
    -------

    """
    return "data_analysis/" + \
           f"{category_name+'/' if category_name else ''}" + \
           f"{'v' + str(version_number) + '/' if version_number else ''}" + \
           f"{run_name}/{run_name}.hdf5"


#
def report_progress(i: int, NT: int, beginning_time = None):
    """
    Prints out a message on how many iterations out of how many total have been completed.

    Parameters
    ----------
    i : int
        Current iteration number
    NT : int
        Total iteration number

    Examples
    ----------
    >>> report_progress(0, 128)
    0/128 iterations (0%) done!
    >>> report_progress(33, 200)
    33/200 iterations (16%) done!
    >>> report_progress(200, 200)
    200/200 iterations (100%) done!

    """
    start_string = f"{i}/{NT} iterations ({i/NT*100:.0f}%) done!"
    if beginning_time and i > 0:
        iterations_left = NT - i
        time_delta = time.time() - beginning_time
        time_per_iteration = time_delta / i
        estimated_remaining_time = iterations_left * time_per_iteration
        start_string += f" Estimated {estimated_remaining_time:.0f}s left."<commit_msg>Display runtime<commit_after># coding=utf-8
import argparse
import errno
import os
import time
# from ..classes import load_simulation
import subprocess

import numpy as np


def config_filename(run_name, category_name=None, version_number=None):
    """
    Prepares config filename for saving.

    Parameters
    ----------
    run_name : str

    category_name : str

    version_number : int


    Examples
    ----------
    >>> config_filename("run")
    'data_analysis/run/run.hdf5'
    >>> config_filename("run", "simulation_type")
    'data_analysis/simulation_type/run/run.hdf5'
    >>> config_filename("run", "simulation_type", 1)
    'data_analysis/simulation_type/v1/run/run.hdf5'

    Returns
    -------

    """
    return "data_analysis/" + \
           f"{category_name+'/' if category_name else ''}" + \
           f"{'v' + str(version_number) + '/' if version_number else ''}" + \
           f"{run_name}/{run_name}.hdf5"


#
def report_progress(i: int, NT: int, beginning_time = None):
    """
    Prints out a message on how many iterations out of how many total have been completed.

    Parameters
    ----------
    i : int
        Current iteration number
    NT : int
        Total iteration number

    Examples
    ----------
    >>> report_progress(0, 128)
    0/128 iterations (0%) done!
    >>> report_progress(33, 200)
    33/200 iterations (16%) done!
    >>> report_progress(200, 200)
    200/200 iterations (100%) done!

    """
    start_string = f"{i}/{NT} iterations ({i/NT*100:.0f}%) done!"
    if beginning_time and i > 0:
        iterations_left = NT - i
        time_delta = time.time() - beginning_time
        time_per_iteration = time_delta / i
        estimated_remaining_time = iterations_left * time_per_iteration
        start_string += f" Current runtime: {time_delta:.0f}s; {estimated_remaining_time:.0f}s estimated left."
{'fraction_non_alphanumeric': 0.13739224137931033, 'fraction_numerical': 0.026670258620689655, 'mean_word_length': 2.583976833976834, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 41, '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': '5309097', 'n_tokens_mistral': 1243, 'n_tokens_neox': 1145, 'n_words': 281}