(self, inst)
return np.array(values[:nattrs]), np.array(values[nattrs:]),\
               np.array(metas, dtype=object)
Convert a data instance from another domain to this domain.

        :param inst: The data instance to be converted
        :return: The data instance in this domain
Convert a data instance from another domain to this domain.
Convert a data instance from another domain to this domain .
def convert(self, inst):
        """
        Convert a data instance from another domain to this domain.

        :param inst: The data instance to be converted
        :return: The data instance in this domain
        """
        from .instance import Instance

        if isinstance(inst, Instance):
            if inst.domain == self:
                return inst._x, inst._y, inst._metas
            c = DomainConversion(inst.domain, self)
            l = len(inst.domain.attributes)
            values = [(inst._x[i] if 0 <= i < l
                       else inst._y[i - l] if i >= l
                       else inst._metas[-i - 1])
                      if isinstance(i, int)
                      else (Unknown if not i else i(inst))
                      for i in c.variables]
            metas = [(inst._x[i] if 0 <= i < l
                      else inst._y[i - l] if i >= l
                      else inst._metas[-i - 1])
                     if isinstance(i, int)
                     else (Unknown if not i else i(inst))
                     for i in c.metas]
        else:
            nvars = len(self._variables)
            nmetas = len(self._metas)
            if len(inst) != nvars and len(inst) != nvars + nmetas:
                raise ValueError("invalid data length for domain")
            values = [var.to_val(val)
                      for var, val in zip(self._variables, inst)]
            if len(inst) == nvars + nmetas:
                metas = [var.to_val(val)
                         for var, val in zip(self._metas, inst[nvars:])]
            else:
                metas = [var.Unknown for var in self._metas]
        nattrs = len(self.attributes)
        # Let np.array decide dtype for values
        return np.array(values[:nattrs]), np.array(values[nattrs:]),\
               np.array(metas, dtype=object)
def convert ( self , inst ) : from . instance import Instance if isinstance ( inst , Instance ) : if inst . domain == self : return inst . _x , inst . _y , inst . _metas c = DomainConversion ( inst . domain , self ) l = len ( inst . domain . attributes ) values = [ ( inst . _x [ i ] if 0 <= i < l else inst . _y [ i - l ] if i >= l else inst . _metas [ - i - 1 ] ) if isinstance ( i , int ) else ( Unknown if not i else i ( inst ) ) for i in c . variables ] metas = [ ( inst . _x [ i ] if 0 <= i < l else inst . _y [ i - l ] if i >= l else inst . _metas [ - i - 1 ] ) if isinstance ( i , int ) else ( Unknown if not i else i ( inst ) ) for i in c . metas ] else : nvars = len ( self . _variables ) nmetas = len ( self . _metas ) if len ( inst ) != nvars and len ( inst ) != nvars + nmetas : raise ValueError ( "invalid data length for domain" ) values = [ var . to_val ( val ) for var , val in zip ( self . _variables , inst ) ] if len ( inst ) == nvars + nmetas : metas = [ var . to_val ( val ) for var , val in zip ( self . _metas , inst [ nvars : ] ) ] else : metas = [ var . Unknown for var in self . _metas ] nattrs = len ( self . attributes ) # Let np.array decide dtype for values return np . array ( values [ : nattrs ] ) , np . array ( values [ nattrs : ] ) , np . array ( metas , dtype = object )