<commit_before>__author__ = '<NAME>'

from apsis.models.candidate import Candidate
from apsis.models.parameter_definition import ParamDef
import copy
import uuid


class Experiment(object):
    """
    An Experiment is a set of parameter definitions and multiple candidate
    evaluations thereon.

    Attributes
    ----------
    name : string
        The name of the experiment. This does not have to be unique, but is
        for human orientation.
    parameter_definitions : dict of ParamDefs
        A dictionary of ParamDef instances. These define the parameter space
        over which optimization is possible.
    minimization_problem : bool
        Defines whether the experiment's goal is to find a minimum result - for
        example when evaluating errors - or a maximum result - for example when
        evaluating scores.
    candidates_pending : list of Candidate instances
        These Candidate instances have been generated by an optimizer to be
        evaluated at the next possible time, but are not yet assigned to a
        worker.
    candidates_working : list of Candidate instances
        These Candidate instances are currently being evaluated by workers.
    candidates_finished : list of Candidate instances
        These Candidate instances have finished evaluated.
    best_candidate : Candidate instance
        The as of yet best Candidate instance found, according to the result.
    note : string, optional
        The note can be used to add additional human-readable information to
        the experiment.
    """
    name = None

    parameter_definitions = None
    minimization_problem = None

    notes = None
    exp_id = None

    candidates_pending = None
    candidates_working = None
    candidates_finished = None

    best_candidate = None

    def __init__(self, name, parameter_definitions, exp_id=None, notes=None, minimization_problem=True,):
        """
        Initializes an Experiment with a certain parameter definition.

        All of the Candidate lists are set to empty lists, representing an
        experiment with no work done.

        Parameters
        ----------
        name : string
            The name of the experiment. This does not have to be unique, but is
            for human orientation.

        parameter_definitions : dict of ParamDef
            Defines the parameter space of the experiment. Each entry of the
            dictionary has to be a ParamDef, and it is that space over which
            optimization will occur.
        minimization_problem : bool, optional
            Defines whether the experiment's goal is to find a minimum result - for
            example when evaluating errors - or a maximum result - for example when
            evaluating scores. Is True by default.
        notes : string or None, optional
            The note can be used to add additional human-readable information to
            the experiment.
        Raises
        ------
        ValueError :
            Iff parameter_definitions are not a dictionary.
        """
        self.name = name
        if exp_id is None:
            exp_id = uuid.uuid4()
        self.exp_id = exp_id
        if not isinstance(parameter_definitions, dict):
            raise ValueError("parameter_definitions are not a dict.")
        for p in parameter_definitions:
            if not isinstance(parameter_definitions[p], ParamDef):
                raise ValueError("Parameter definition of %s is not a ParamDef."
                                 %p)
        self.parameter_definitions = parameter_definitions

        self.minimization_problem = minimization_problem

        self.candidates_finished = []
        self.candidates_pending = []<commit_msg>Fixed id generation as hex string.<commit_after>__author__ = '<NAME>'

from apsis.models.candidate import Candidate
from apsis.models.parameter_definition import ParamDef
import copy
import uuid


class Experiment(object):
    """
    An Experiment is a set of parameter definitions and multiple candidate
    evaluations thereon.

    Attributes
    ----------
    name : string
        The name of the experiment. This does not have to be unique, but is
        for human orientation.
    parameter_definitions : dict of ParamDefs
        A dictionary of ParamDef instances. These define the parameter space
        over which optimization is possible.
    minimization_problem : bool
        Defines whether the experiment's goal is to find a minimum result - for
        example when evaluating errors - or a maximum result - for example when
        evaluating scores.
    candidates_pending : list of Candidate instances
        These Candidate instances have been generated by an optimizer to be
        evaluated at the next possible time, but are not yet assigned to a
        worker.
    candidates_working : list of Candidate instances
        These Candidate instances are currently being evaluated by workers.
    candidates_finished : list of Candidate instances
        These Candidate instances have finished evaluated.
    best_candidate : Candidate instance
        The as of yet best Candidate instance found, according to the result.
    note : string, optional
        The note can be used to add additional human-readable information to
        the experiment.
    """
    name = None

    parameter_definitions = None
    minimization_problem = None

    notes = None
    exp_id = None

    candidates_pending = None
    candidates_working = None
    candidates_finished = None

    best_candidate = None

    def __init__(self, name, parameter_definitions, exp_id=None, notes=None, minimization_problem=True,):
        """
        Initializes an Experiment with a certain parameter definition.

        All of the Candidate lists are set to empty lists, representing an
        experiment with no work done.

        Parameters
        ----------
        name : string
            The name of the experiment. This does not have to be unique, but is
            for human orientation.

        parameter_definitions : dict of ParamDef
            Defines the parameter space of the experiment. Each entry of the
            dictionary has to be a ParamDef, and it is that space over which
            optimization will occur.
        minimization_problem : bool, optional
            Defines whether the experiment's goal is to find a minimum result - for
            example when evaluating errors - or a maximum result - for example when
            evaluating scores. Is True by default.
        notes : string or None, optional
            The note can be used to add additional human-readable information to
            the experiment.
        Raises
        ------
        ValueError :
            Iff parameter_definitions are not a dictionary.
        """
        self.name = name
        if exp_id is None:
            exp_id = uuid.uuid4().hex
        self.exp_id = exp_id
        if not isinstance(parameter_definitions, dict):
            raise ValueError("parameter_definitions are not a dict.")
        for p in parameter_definitions:
            if not isinstance(parameter_definitions[p], ParamDef):
                raise ValueError("Parameter definition of %s is not a ParamDef."
                                 %p)
        self.parameter_definitions = parameter_definitions

        self.minimization_problem = minimization_problem

        self.candidates_finished = []
        self.candidates_pending = []
{'fraction_non_alphanumeric': 0.04603238324635354, 'fraction_numerical': 0.00026763013515321824, 'mean_word_length': 2.3041556145004423, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4715456', 'n_tokens_mistral': 1707, 'n_tokens_neox': 1694, 'n_words': 773}