(
            self, name="", values=(), compute_value=None, *, sparse=False
    )
Construct a discrete variable descriptor with the given values.
Construct a discrete variable descriptor with the given values.
Construct a discrete variable descriptor with the given values .
def __init__(
            self, name="", values=(), compute_value=None, *, sparse=False
    ):
        """ Construct a discrete variable descriptor with the given values. """
        values = tuple(values)  # some people (including me) pass a generator
        if not all(isinstance(value, str) for value in values):
            raise TypeError("values of DiscreteVariables must be strings")

        super().__init__(name, compute_value, sparse=sparse)
        self._values = values
        self._value_index = {value: i for i, value in enumerate(values)}
def __init__ ( self , name = "" , values = ( ) , compute_value = None , * , sparse = False ) : values = tuple ( values ) # some people (including me) pass a generator if not all ( isinstance ( value , str ) for value in values ) : raise TypeError ( "values of DiscreteVariables must be strings" ) super ( ) . __init__ ( name , compute_value , sparse = sparse ) self . _values = values self . _value_index = { value : i for i , value in enumerate ( values ) }