<commit_before>"""
A set of objects that allows declarative specification of a model
including training patterns, sheets and projections.

The components of a model specification can be individually inspected,
modified, resolved or instantiated.
"""

import topo
import param

from dataviews.collector import AttrTree
from collections import OrderedDict


class Specification(param.Parameterized):
    """
    Specifications are templates for sheet or projection objects which
    may be resolved to the corresponding simulation object once
    instantiated.

    All specifications have the following attribute:

    :'parameters': Keyword argument dictionary specifying which
    parameters should be passed to the sheet or projection object.
    """

    def update(self, **params):
        """
        Convenience method to easy update specification parameters.
        """
        self.parameters.update(params)

    @property
    def modified_parameters(self):
        "Dictionary of modified specification parameters"
        return {k:v for k, v in self.parameters.items()
                if self.default_parameters[k] != v}


    def resolve(self):
        """
        Returns the object in topo.sim corresponding to the string
        name of this object, typically a Sheet or a Projection.

        The appropriate object must be instantiated in topo.sim first.
        """
        from topo import sim # pyflakes:ignore (needed for eval)
        return eval('sim.'+str(self))


    def __lt__(self, other):
        return self.sort_precedence < other.sort_precedence

    def __eq__(self, other):
        return self.sort_precedence == other.sort_precedence

    def __init__(self, object_type):
        self.parameters = {}
        self.sort_precedence = 0<commit_msg>Added resolved_type to Specifications for use with Collector<commit_after>"""
A set of objects that allows declarative specification of a model
including training patterns, sheets and projections.

The components of a model specification can be individually inspected,
modified, resolved or instantiated.
"""

import topo
import param

from dataviews.collector import AttrTree
from collections import OrderedDict


class Specification(param.Parameterized):
    """
    Specifications are templates for sheet or projection objects which
    may be resolved to the corresponding simulation object once
    instantiated.

    All specifications have the following attribute:

    :'parameters': Keyword argument dictionary specifying which
    parameters should be passed to the sheet or projection object.
    """

    def update(self, **params):
        """
        Convenience method to easy update specification parameters.
        """
        self.parameters.update(params)

    @property
    def modified_parameters(self):
        "Dictionary of modified specification parameters"
        return {k:v for k, v in self.parameters.items()
                if self.default_parameters[k] != v}


    @property
    def resolved_type(self):
        return self._object_type


    def resolve(self):
        """
        Returns the object in topo.sim corresponding to the string
        name of this object, typically a Sheet or a Projection.

        The appropriate object must be instantiated in topo.sim first.
        """
        from topo import sim # pyflakes:ignore (needed for eval)
        return eval('sim.'+str(self))


    def __lt__(self, other):
        return self.sort_precedence < other.sort_precedence

    def __eq__(self, other):
        return self.sort_precedence == other.sort_precedence

    def __init__(self, object_type):
        self._object_type = object_type
        self.parameters = {}
        self.sort_precedence = 0
{'fraction_non_alphanumeric': 0.06573651730614435, 'fraction_numerical': 0.0005366246310705661, 'mean_word_length': 3.0521739130434784, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7198220', 'n_tokens_mistral': 956, 'n_tokens_neox': 887, 'n_words': 361}