Beispiel #1
0
    def setOutputInputAttributes(self, inAttNames, outAttNames):
        i = 0
        attName = ""
        att = Attribute()

        for i in range(0, len(self.__attributes)):
            att = Attribute(self.__attributes[i])
            attName = att.getName()
            if (attName in inAttNames):
                att.setDirectionAttribute(Attribute.INPUT)
                self.__inputAttr.append(self.__attributes[i])
            elif (attName in outAttNames):
                att.setDirectionAttribute(Attribute.OUTPUT)
                self.__outputAttr.append(self.__attributes[i])
            else:
                self.__undefinedAttr.append(self.__attributes[i])

        #Finally, making some statistics
        self.__hasNominal = False
        self.__hasInteger = False
        self.__hasReal = False

        for index in range(0, 2):
            if (index == 0):
                iterations = len(self._inputAttr)
            else:
                iterations = len(self._outputAttr)

            for i in range(0, iterations):

                if (index == 0):
                    att = Attribute(self._inputAttr[i])
                else:
                    att = Attribute(self._outputAttr[i])
                if (att.getType() == Attribute.NOMINAL):

                    self.__hasNominal = True

                elif (att.getType() == Attribute.INTEGER):
                    self.__hasInteger = True

                elif (att.getType() == Attribute.REAL):
                    self.__hasReal = True
Beispiel #2
0
    def removeAttribute(self, inputAtt, whichAtt):
        atToDel = None
        if (inputAtt and (whichAtt >= len(self._inputAttr) or whichAtt < 0)):
            return False
        if (self.__inputAtt
                and (whichAtt >= len(self.__outputAttr) or whichAtt < 0)):
            return False

        if (inputAtt):
            #inputAttribute
            atToDel = Attribute(self.__inputAttr[whichAtt])
            atToDel.setDirectionAttribute(Attribute.DIR_NOT_DEF)
            self.__inputAttr.removeElementAt(whichAtt)

        else:  #output attribute
            atToDel = Attribute(self.__outputAttr[whichAtt])
            atToDel.setDirectionAttribute(Attribute.DIR_NOT_DEF)
            self.__outputAttr.removeElementAt(whichAtt)

        #We get the position where it has to go in the undefined attributes vector.
        self.__undefPosition = self.searchUndefPosition(atToDel)
        self.__undefinedAttr.insertElementAt(atToDel, self.__undefPosition)

        self.__hasNominal = False
        self.__hasInteger = False
        self.__hasReal = False
        for index in (0, 2):
            iterations = 0
            if (index == 0):
                iterations = len(self.__inputAttr)
            else:
                iterations = len(self.__outputAttr)
            for i in range(0, iterations):
                if (index == 0):
                    att = Attribute(self.__inputAttr[i])
                else:
                    att = Attribute(self.__outputAttr[i])
            attTypeHere = att.getType()
            if (attTypeHere == Attribute.NOMINAL):

                self.__hasNominal = True

            elif (attTypeHere == Attribute.INTEGER):
                self.__hasInteger = True

            elif (attTypeHere == Attribute.REAL):
                self.__hasReal = True

        return True