<commit_before>"""
Parameters are a kind of class attribute allowing special behavior,
including dynamically generated parameter values, documentation
strings, constant and read-only parameters, and type or range checking
at assignment time.

Potentially useful for any large Python program that needs
user-modifiable object attributes; see the parameterized.Parameter and
parameterized.Parameterized classes for more information.


This file contains subclasses of Parameter, implementing specific
parameter types (e.g. Number).

$Id$
"""
__version__='$Revision$'

# CEBALERT: we'll need more documentation above (eventually, when
# params becomes a separate directory and then package).

import types

from parameterized import Parameter, descendents


class Enumeration(Parameter):
    """
    Enumeration is a Parameter with a list of available values.

    An Enumeration's value is always one from its list of available values.
    """
    __slots__ = ['available']

    def __init__(self, default=None, available=[], **params):
        """
        Create an Enumeration, checking that 'default' is in 'available'.
        """
        try:
            default in available
        except TypeError, te:
            raise TypeError("Enumeration's 'available' argument must be iterable ('%s' is not iterable)."%available)<commit_msg>Temporarily (?) added Parameterized to simplify imports<commit_after>"""
Parameters are a kind of class attribute allowing special behavior,
including dynamically generated parameter values, documentation
strings, constant and read-only parameters, and type or range checking
at assignment time.

Potentially useful for any large Python program that needs
user-modifiable object attributes; see the parameterized.Parameter and
parameterized.Parameterized classes for more information.


This file contains subclasses of Parameter, implementing specific
parameter types (e.g. Number).

$Id$
"""
__version__='$Revision$'

# CEBALERT: we'll need more documentation above (eventually, when
# params becomes a separate directory and then package).

import types

from parameterized import Parameterized, Parameter, descendents


class Enumeration(Parameter):
    """
    Enumeration is a Parameter with a list of available values.

    An Enumeration's value is always one from its list of available values.
    """
    __slots__ = ['available']

    def __init__(self, default=None, available=[], **params):
        """
        Create an Enumeration, checking that 'default' is in 'available'.
        """
        try:
            default in available
        except TypeError, te:
            raise TypeError("Enumeration's 'available' argument must be iterable ('%s' is not iterable)."%available)
{'fraction_non_alphanumeric': 0.074697912852435, 'fraction_numerical': 0.0, 'mean_word_length': 4.059259259259259, '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': '4298072', 'n_tokens_mistral': 665, 'n_tokens_neox': 632, 'n_words': 297}