Values (value)

class, value=nan)[source]

The class representing a value. The class is not used to store values but only to return them in contexts in which we want the value to be accompanied with the descriptor, for instance to print the symbolic value of discrete variables.

The class is derived from float, with an additional attribute variable which holds the descriptor of type If the value continuous or discrete, it is stored as a float. Other types of values, like strings, are stored in the attribute value.

The class overloads the methods for printing out the value: variable.repr_val and variable.str_val are used to get a suitable representation of the value.

Equivalence operator is overloaded as follows:

  • unknown values are equal; if one value is unknown and the other is not, they are different;

  • if the value is compared with the string, the value is converted to a string using variable.str_val and the two strings are compared

  • if the value is stored in attribute value, it is compared with the given other value

  • otherwise, the inherited comparison operator for float is called.

Finally, value defines a hash, so values can be put in sets and appear as keys in dictionaries.


Descriptor; used for printing out and for comparing with strings


Value; the value can be of arbitrary type and is used only for variables that are neither discrete nor continuous. If value is None, the derived float value is used.