Commits

Aleš Erjavec  committed c521b70

Handle input matrices without (or with nonstandard) 'items' attribute.

(references #1264)

  • Participants
  • Parent commits fab0b2b

Comments (0)

Files changed (1)

File Orange/OrangeWidgets/Unsupervised/OWMDS.py

         self.controlArea.setMinimumWidth(250)
 
         OWGUI.rubber(mds)
+        OWGUI.rubber(graph)
 
         infoBox = OWGUI.widgetBox(mds, "Info")
         self.infoA = OWGUI.widgetLabel(infoBox, "Avg. stress:")
         self.origMatrix = matrix
         self.data = data = None
         if matrix:
-            self.data = data = getattr(matrix, "items")
+            self.data = data = getattr(matrix, "items", range(matrix.dim))
             matrix.matrixType = orange.SymMatrix.Symmetric
 
         self.graph.ColorAttr = 0
             self.setExampleTable(data)
         elif isinstance(data, orange.VarList):
             self.setVarList(data)
+        elif data is not None:
+            self.setList(data)
 
         if matrix:
             self.mds = orngMDS.MDS(matrix)
         except Exception, val:
             print val
 
+    def setList(self, data):
+        self.colorCombo.clear()
+        self.sizeCombo.clear()
+        self.shapeCombo.clear()
+        self.nameCombo.clear()
+
+        for name in ["No name", "Item string"]:
+            self.nameCombo.addItem(name)
+
+        self.colors = [[Qt.black] for i in range(len(data))]
+        self.shapes = [[QwtSymbol.Ellipse] for i in range(len(data))]
+        self.sizes = [[5] for i in range(len(data))]
+        self.selectedInput = [False] * len(data)
+
+        self.names = [("", str(item)) for item in data]
+
     def updateStressBySize(self, noRepaint=False):
         self.sizeCombo.setDisabled(self.graph.stressBySize)
         if not noRepaint: