(self, attributes, class_vars=None, metas=None, source=None)
Initialize a new domain descriptor. Arguments give the features and
        the class attribute(s). They can be described by descriptors (instances
        of :class:`Variable`), or by indices or names if the source domain is
        given.

        :param attributes: a list of attributes
        :type attributes: list of :class:`Variable`
        :param class_vars: target variable or a list of target variables
        :type class_vars: :class:`Variable` or list of :class:`Variable`
        :param metas: a list of meta attributes
        :type metas: list of :class:`Variable`
        :param source: the source domain for attributes
        :type source: Orange.data.Domain
        :return: a new domain
        :rtype: :class:`Domain`
Initialize a new domain descriptor. Arguments give the features and
        the class attribute(s). They can be described by descriptors (instances
        of :class:`Variable`), or by indices or names if the source domain is
        given.
Initialize a new domain descriptor . Arguments give the features and the class attribute ( s ) . They can be described by descriptors ( instances of : class : Variable ) or by indices or names if the source domain is given .
def __init__(self, attributes, class_vars=None, metas=None, source=None):
        """
        Initialize a new domain descriptor. Arguments give the features and
        the class attribute(s). They can be described by descriptors (instances
        of :class:`Variable`), or by indices or names if the source domain is
        given.

        :param attributes: a list of attributes
        :type attributes: list of :class:`Variable`
        :param class_vars: target variable or a list of target variables
        :type class_vars: :class:`Variable` or list of :class:`Variable`
        :param metas: a list of meta attributes
        :type metas: list of :class:`Variable`
        :param source: the source domain for attributes
        :type source: Orange.data.Domain
        :return: a new domain
        :rtype: :class:`Domain`
        """

        if class_vars is None:
            class_vars = []
        elif isinstance(class_vars, (Variable, Integral, str)):
            class_vars = [class_vars]
        elif isinstance(class_vars, Iterable):
            class_vars = list(class_vars)

        if not isinstance(attributes, list):
            attributes = list(attributes)
        metas = list(metas) if metas else []

        # Replace str's and int's with descriptors if 'source' is given;
        # complain otherwise
        for lst in (attributes, class_vars, metas):
            for i, var in enumerate(lst):
                if not isinstance(var, Variable):
                    if source is not None and isinstance(var, (str, int)):
                        lst[i] = source[var]
                    else:
                        raise TypeError(
                            "descriptors must be instances of Variable, "
                            "not '%s'" % type(var).__name__)

        names = [var.name for var in chain(attributes, class_vars, metas)]
        if len(names) != len(set(names)):
            raise Exception('All variables in the domain should have'
                            ' unique names.')

        # Store everything
        self.attributes = tuple(attributes)
        self.class_vars = tuple(class_vars)
        self._variables = self.attributes + self.class_vars
        self._metas = tuple(metas)
        self.class_var = \
            self.class_vars[0] if len(self.class_vars) == 1 else None
        if not all(var.is_primitive() for var in self._variables):
            raise TypeError("variables must be primitive")

        self._indices = dict(chain.from_iterable(
            ((var, idx), (var.name, idx), (idx, idx))
            for idx, var in enumerate(self._variables)))
        self._indices.update(chain.from_iterable(
            ((var, -1-idx), (var.name, -1-idx), (-1-idx, -1-idx))
            for idx, var in enumerate(self.metas)))

        self.anonymous = False

        self._hash = None
def __init__ ( self , attributes , class_vars = None , metas = None , source = None ) : if class_vars is None : class_vars = [ ] elif isinstance ( class_vars , ( Variable , Integral , str ) ) : class_vars = [ class_vars ] elif isinstance ( class_vars , Iterable ) : class_vars = list ( class_vars ) if not isinstance ( attributes , list ) : attributes = list ( attributes ) metas = list ( metas ) if metas else [ ] # Replace str's and int's with descriptors if 'source' is given; # complain otherwise for lst in ( attributes , class_vars , metas ) : for i , var in enumerate ( lst ) : if not isinstance ( var , Variable ) : if source is not None and isinstance ( var , ( str , int ) ) : lst [ i ] = source [ var ] else : raise TypeError ( "descriptors must be instances of Variable, " "not '%s'" % type ( var ) . __name__ ) names = [ var . name for var in chain ( attributes , class_vars , metas ) ] if len ( names ) != len ( set ( names ) ) : raise Exception ( 'All variables in the domain should have' ' unique names.' ) # Store everything self . attributes = tuple ( attributes ) self . class_vars = tuple ( class_vars ) self . _variables = self . attributes + self . class_vars self . _metas = tuple ( metas ) self . class_var = self . class_vars [ 0 ] if len ( self . class_vars ) == 1 else None if not all ( var . is_primitive ( ) for var in self . _variables ) : raise TypeError ( "variables must be primitive" ) self . _indices = dict ( chain . from_iterable ( ( ( var , idx ) , ( var . name , idx ) , ( idx , idx ) ) for idx , var in enumerate ( self . _variables ) ) ) self . _indices . update ( chain . from_iterable ( ( ( var , - 1 - idx ) , ( var . name , - 1 - idx ) , ( - 1 - idx , - 1 - idx ) ) for idx , var in enumerate ( self . metas ) ) ) self . anonymous = False self . _hash = None