Commits

Aleš Erjavec committed 7343891

Fixed an IndexError in LinearProjection and Polyviz widget.

This occurred when the number of classes exceeded the number of available
distinct point symbols.

(fixes #1348)

Comments (0)

Files changed (2)

Orange/OrangeWidgets/Visualize/OWLinProjGraph.py

         if self.dataHasDiscreteClass:
             self.discPalette.setNumberOfColors(len(self.dataDomain.classVar.values))
 
-        useDifferentSymbols = self.useDifferentSymbols and self.dataHasDiscreteClass and len(self.dataDomain.classVar.values) < len(self.curveSymbols)
+        useDifferentSymbols = self.useDifferentSymbols and self.dataHasDiscreteClass and len(self.dataDomain.classVar.values) <= len(self.curveSymbols)
         dataSize = len(self.rawData)
         validData = self.getValidList(indices)
         # jitter point if Radviz
                 else:
                     newColor = (0,0,0)
 
-                if self.useDifferentSymbols and self.dataHasDiscreteClass:
+                if useDifferentSymbols:
                     curveSymbol = self.curveSymbols[int(self.originalData[self.dataClassIndex][i])]
                 else:
                     curveSymbol = self.curveSymbols[0]
                     else:
                         newColor = self.contPalette.getRGB(self.noJitteringScaledSubsetData[self.dataClassIndex][i])
 
-                if self.useDifferentSymbols and self.dataHasDiscreteClass and self.validSubsetDataArray[self.dataClassIndex][i]:
+                if useDifferentSymbols and self.validSubsetDataArray[self.dataClassIndex][i]:
                     curveSymbol = self.curveSymbols[int(self.originalSubsetData[self.dataClassIndex][i])]
                 else:
                     curveSymbol = self.curveSymbols[0]
         # ##############################################################
         elif self.dataHasDiscreteClass:
             for i in range(dataSize):
-                if not validData[i]: continue
-                if self.useDifferentColors: newColor = self.discPalette.getRGB(self.originalData[self.dataClassIndex][i])
-                else:                       newColor = (0,0,0)
-                if self.useDifferentSymbols: curveSymbol = self.curveSymbols[int(self.originalData[self.dataClassIndex][i])]
-                else:                        curveSymbol = self.curveSymbols[0]
+                if not validData[i]:
+                    continue
+                if self.useDifferentColors:
+                    newColor = self.discPalette.getRGB(self.originalData[self.dataClassIndex][i])
+                else:
+                    newColor = (0, 0, 0)
+                if useDifferentSymbols:
+                    curveSymbol = self.curveSymbols[int(self.originalData[self.dataClassIndex][i])]
+                else:
+                    curveSymbol = self.curveSymbols[0]
                 if not xPointsToAdd.has_key((newColor, curveSymbol, self.showFilledSymbols)):
                     xPointsToAdd[(newColor, curveSymbol, self.showFilledSymbols)] = []
                     yPointsToAdd[(newColor, curveSymbol, self.showFilledSymbols)] = []
                     else:                       color = QColor(Qt.black)
                     y = 1.0 - index * 0.05
 
-                    if not self.useDifferentSymbols:  curveSymbol = self.curveSymbols[0]
-                    else:                             curveSymbol = self.curveSymbols[index]
+                    if not useDifferentSymbols:
+                        curveSymbol = self.curveSymbols[0]
+                    else:
+                        curveSymbol = self.curveSymbols[index]
 
                     self.addCurve(str(index), color, color, self.pointWidth, symbol = curveSymbol, xData = [0.95], yData = [y], penAlpha = self.alphaValue, brushAlpha = self.alphaValue)
                     self.addMarker(classVariableValues[index], 0.90, y, Qt.AlignLeft | Qt.AlignVCenter)

Orange/OrangeWidgets/Visualize/OWPolyvizGraph.py

         indices = [self.attributeNameIndex[label] for label in labels]
 
         # will we show different symbols?
-        useDifferentSymbols = self.useDifferentSymbols and self.dataHasDiscreteClass and len(self.dataDomain.classVar.values) < len(self.curveSymbols)
+        useDifferentSymbols = self.useDifferentSymbols and self.dataHasDiscreteClass and len(self.dataDomain.classVar.values) <= len(self.curveSymbols)
 
         # ##########
         # draw text at lines
             for i in range(dataSize):
                 if not validData[i]: continue
                 if self.dataHasClass:
-                    if self.useDifferentSymbols:
+                    if useDifferentSymbols:
                         symbol = self.curveSymbols[int(self.originalData[self.dataClassIndex][i])]
                     if useDifferentColors:
                         color = self.discPalette.getRGB(self.originalData[self.dataClassIndex][i])
                     else:                       color = QColor(0,0,0)
                     y = 1.0 - index * 0.05
 
-                    if not self.useDifferentSymbols:  curveSymbol = self.curveSymbols[0]
-                    else:                             curveSymbol = self.curveSymbols[index]
+                    if not useDifferentSymbols:
+                        curveSymbol = self.curveSymbols[0]
+                    else:
+                        curveSymbol = self.curveSymbols[index]
 
                     self.addCurve(str(index), color, color, self.pointWidth, symbol = curveSymbol, xData = [0.95, 0.95], yData = [y, y])
                     self.addMarker(classVariableValues[index], 0.90, y, Qt.AlignLeft | Qt.AlignVCenter)