Commits

Anonymous committed b522e18

progress bar
does not fail when all values of attribute missing

Comments (0)

Files changed (1)

OWDisplayProfiles.py

         self.averageProfileCurveKeys = []
         self.showClasses = []
 
-    def setData(self, data, classColor, classBrighterColor, ShowAverageProfile, ShowSingleProfiles):
+    def setData(self, data, classColor, classBrighterColor, ShowAverageProfile, ShowSingleProfiles, progressBar = None):
         self.removeCurves()
         self.classColor = classColor
         self.classBrighterColor = classBrighterColor
         if data.domain.classVar.varType <> orange.VarTypes.Discrete:
             print "error, class variable not discrete:", data.domain.classVar
             return
+        allc = len(data.domain.classVar.values)
         for c in data.domain.classVar.values:
+            if progressBar <> None: progressBar(int(ccn*100.0/allc))
             classSymb = QwtSymbol(QwtSymbol.Ellipse, QBrush(self.classColor[ccn]), QPen(self.classColor[ccn]), QSize(7,7)) ##self.black
             self.showClasses.append(0)
 
             self.profileCurveKeys.append([])
             self.averageProfileCurveKeys.append([])
+            allg = len(self.groups)
+            gcn = 0
             grpcnx = 0
             for (grpname, grpattrs) in self.groups:
                 oneClassData = data.select({data.domain.classVar.name:c})
                 ## single profiles
                 nativeData = oneGrpData.native(2)
                 yVals = [[] for cn in range(len(grpattrs))]
+                alle = len(nativeData)
+                ecn = 0
                 for e in nativeData:
+                    ecn += 1
+                    progress = 100.0*(ccn + (float(gcn)/allg) * (float(ecn)/alle))
+                    progress = int(round(progress / allc))
+                    if progressBar <> None: progressBar(progress)
                     y = []
                     x = []
                     xcn = grpcnx
                 vcn = 0
                 dist = orange.DomainDistributions(oneGrpData)
                 for a in dist:
-                    if a:
+                    if a and len(a) > 0:
                         ## box plot data
                         yavg = a.average()
                         yq1 = a.percentile(25)
                         BPy.append( yavg )
                         BPy.append( yqM )
                         BPy.append( yq1 )
-                        BPy.append( smallestAdjacentValue )                       
+                        BPy.append( smallestAdjacentValue )
                         BPx.append( xcn )
                         BPx.append( xcn )
                         BPx.append( xcn )
 
                 boxPlotCurveData.append( (BPx, BPy, ccn) )
                 grpcnx += len(grpattrs)
+                gcn +=1
             ccn += 1
 
         for (x, y, tmpCcn) in boxPlotCurveData:
     ##
 
     def calcGraph(self):
-        self.graph.setData(self.MAdata, self.classColor, self.classBrighterColor, self.ShowAverageProfile, self.ShowSingleProfiles)
+        self.progressBarInit()
+        self.graph.setData(self.MAdata, self.classColor, self.classBrighterColor, self.ShowAverageProfile, self.ShowSingleProfiles, self.progressBarSet)
         self.graph.setPointWidth(self.PointWidth)
         self.graph.setCurveWidth(self.CurveWidth)
         self.graph.setAverageCurveWidth(self.AverageCurveWidth)
         self.graph.setAxisAutoScale(QwtPlot.xBottom)
         self.graph.setAxisAutoScale(QwtPlot.yLeft)
         self.graph.replot()
+        self.progressBarFinished()
 
     def newdata(self):
         self.classQLB.clear()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.