PEATDB/Ekin/Ekin_main.py
def showBestModelDialog(self):
        """Find the best model using f-test criteria"""

        self.stopvar=IntVar(); self.stopvar.set(0)
        models = EkinProject.mode_definition[self.mode]
        self.fbm_win = Toplevel(self.parent.master)
        self.parentapp.set_geometry(self.parentapp.ekin_win, self.fbm_win)
        self.fbm_win.title('Find best model')

        frame1 = Frame(self.fbm_win)
        frame1.grid(row=0,column=0)
        info = '''Select models to include in the test, models\n must have increasing degrees of freedom\n and must be nested in some meaningful sense\n for this test to be useful'''
        Label(frame1,text=info,bg='yellow').grid(row=0,column=0,columnspan=3)
        self.tempmodelvars={}
        r=1; i=0
        for l in ['name','params',''] :
            Label(frame1,text=l).grid(row=r,column=i)
            i+=1
        r=2
        for m in models:
            self.tempmodelvars[m]=IntVar(); self.tempmodelvars[m].set(0)
            Label(frame1,text=m).grid(row=r,column=0)
            X = Fitting.getFitter(model=m)
            n = len(X.variables)
            Label(frame1,text=n).grid(row=r,column=1)
            Checkbutton(frame1,variable=self.tempmodelvars[m],
                                onvalue=1,offvalue=0).grid(row=r,column=2)
            r+=1

        self.fbresults=Pmw.ScrolledText(self.fbm_win,
                                labelpos = 'n',
                                usehullsize = 1,
                                hull_width = 400,
                                hull_height = 400)
        self.fbresults.grid(row=0,column=1,sticky='news')
        # buttons
        frame3 = Frame(self.fbm_win)
        frame3.grid(row=1,column=0,columnspan=2)

        def update(res, d):
            print 'res',res
            if res == None:
                self.fbresults.insert(END, 'No models selected?\n')
            else:
                self.fbresults.insert(END, '%s: %s' %(d,res['model']))
                self.fbresults.insert(END, '\n')
            self.fbresults.yview("moveto",1.0)
            #we dont update atm because of memory leak
            #self.parentapp.updateAll(d)
            self.update_idletasks()
            frame1.update()

        def go():
            self.stopvar.set(0)
            self.findBestModel(doall=doallvar.get(), callback=update)

        def stop():
            self.stopvar.set(1)

        Button(frame3, text='Go', relief=GROOVE, bg='#B0C4DE',
               command=go).pack(side=LEFT)
        def close():
            self.fbm_win.destroy()
        Button(frame3,text='Close', relief=GROOVE, bg='#B0C4DE',
               command=close).pack(side=LEFT)

        Button(frame3,text='Stop', relief=GROOVE, bg='red',
               command=stop).pack(side=LEFT)
        doallvar = IntVar(); doallvar.set(0)
        Label(frame3,text='do all').pack(side=LEFT)
        Checkbutton(frame3,variable=doallvar,
                            onvalue=1,offvalue=0).pack(side=LEFT)
        return
Find the best model using f-test criteria
Find the best model using f-test criteria
Find the best model using f - test criteria
def showBestModelDialog(self):
        self.stopvar=IntVar(); self.stopvar.set(0)
        models = EkinProject.mode_definition[self.mode]
        self.fbm_win = Toplevel(self.parent.master)
        self.parentapp.set_geometry(self.parentapp.ekin_win, self.fbm_win)
        self.fbm_win.title('Find best model')
        frame1 = Frame(self.fbm_win)
        frame1.grid(row=0,column=0)
        info = '''Select models to include in the test, models\n must have increasing degrees of freedom\n and must be nested in some meaningful sense\n for this test to be useful'''
        Label(frame1,text=info,bg='yellow').grid(row=0,column=0,columnspan=3)
        self.tempmodelvars={}
        r=1; i=0
        for l in ['name','params',''] :
            Label(frame1,text=l).grid(row=r,column=i)
            i+=1
        r=2
        for m in models:
            self.tempmodelvars[m]=IntVar(); self.tempmodelvars[m].set(0)
            Label(frame1,text=m).grid(row=r,column=0)
            X = Fitting.getFitter(model=m)
            n = len(X.variables)
            Label(frame1,text=n).grid(row=r,column=1)
            Checkbutton(frame1,variable=self.tempmodelvars[m],
                                onvalue=1,offvalue=0).grid(row=r,column=2)
            r+=1
        self.fbresults=Pmw.ScrolledText(self.fbm_win,
                                labelpos = 'n',
                                usehullsize = 1,
                                hull_width = 400,
                                hull_height = 400)
        self.fbresults.grid(row=0,column=1,sticky='news')
        frame3 = Frame(self.fbm_win)
        frame3.grid(row=1,column=0,columnspan=2)
        def update(res, d):
            print 'res',res
            if res == None:
                self.fbresults.insert(END, 'No models selected?\n')
            else:
                self.fbresults.insert(END, '%s: %s' %(d,res['model']))
                self.fbresults.insert(END, '\n')
            self.fbresults.yview("moveto",1.0)
            self.update_idletasks()
            frame1.update()
        def go():
            self.stopvar.set(0)
            self.findBestModel(doall=doallvar.get(), callback=update)
        def stop():
            self.stopvar.set(1)
        Button(frame3, text='Go', relief=GROOVE, bg='#B0C4DE',
               command=go).pack(side=LEFT)
        def close():
            self.fbm_win.destroy()
        Button(frame3,text='Close', relief=GROOVE, bg='#B0C4DE',
               command=close).pack(side=LEFT)
        Button(frame3,text='Stop', relief=GROOVE, bg='red',
               command=stop).pack(side=LEFT)
        doallvar = IntVar(); doallvar.set(0)
        Label(frame3,text='do all').pack(side=LEFT)
        Checkbutton(frame3,variable=doallvar,
                            onvalue=1,offvalue=0).pack(side=LEFT)
        return
def showBestModelDialog ( self ) : self . stopvar = IntVar ( ) ; self . stopvar . set ( 0 ) models = EkinProject . mode_definition [ self . mode ] self . fbm_win = Toplevel ( self . parent . master ) self . parentapp . set_geometry ( self . parentapp . ekin_win , self . fbm_win ) self . fbm_win . title ( 'Find best model' ) frame1 = Frame ( self . fbm_win ) frame1 . grid ( row = 0 , column = 0 ) info = '''Select models to include in the test, models\n must have increasing degrees of freedom\n and must be nested in some meaningful sense\n for this test to be useful''' Label ( frame1 , text = info , bg = 'yellow' ) . grid ( row = 0 , column = 0 , columnspan = 3 ) self . tempmodelvars = { } r = 1 ; i = 0 for l in [ 'name' , 'params' , '' ] : Label ( frame1 , text = l ) . grid ( row = r , column = i ) i += 1 r = 2 for m in models : self . tempmodelvars [ m ] = IntVar ( ) ; self . tempmodelvars [ m ] . set ( 0 ) Label ( frame1 , text = m ) . grid ( row = r , column = 0 ) X = Fitting . getFitter ( model = m ) n = len ( X . variables ) Label ( frame1 , text = n ) . grid ( row = r , column = 1 ) Checkbutton ( frame1 , variable = self . tempmodelvars [ m ] , onvalue = 1 , offvalue = 0 ) . grid ( row = r , column = 2 ) r += 1 self . fbresults = Pmw . ScrolledText ( self . fbm_win , labelpos = 'n' , usehullsize = 1 , hull_width = 400 , hull_height = 400 ) self . fbresults . grid ( row = 0 , column = 1 , sticky = 'news' ) frame3 = Frame ( self . fbm_win ) frame3 . grid ( row = 1 , column = 0 , columnspan = 2 ) def update ( res , d ) : print 'res' , res if res == None : self . fbresults . insert ( END , 'No models selected?\n' ) else : self . fbresults . insert ( END , '%s: %s' % ( d , res [ 'model' ] ) ) self . fbresults . insert ( END , '\n' ) self . fbresults . yview ( "moveto" , 1.0 ) self . update_idletasks ( ) frame1 . update ( ) def go ( ) : self . stopvar . set ( 0 ) self . findBestModel ( doall = doallvar . get ( ) , callback = update ) def stop ( ) : self . stopvar . set ( 1 ) Button ( frame3 , text = 'Go' , relief = GROOVE , bg = '#B0C4DE' , command = go ) . pack ( side = LEFT ) def close ( ) : self . fbm_win . destroy ( ) Button ( frame3 , text = 'Close' , relief = GROOVE , bg = '#B0C4DE' , command = close ) . pack ( side = LEFT ) Button ( frame3 , text = 'Stop' , relief = GROOVE , bg = 'red' , command = stop ) . pack ( side = LEFT ) doallvar = IntVar ( ) ; doallvar . set ( 0 ) Label ( frame3 , text = 'do all' ) . pack ( side = LEFT ) Checkbutton ( frame3 , variable = doallvar , onvalue = 1 , offvalue = 0 ) . pack ( side = LEFT ) return
Find the best model using f-test criteria
Find the best model using f - test criteria
"""Find the best model using f-test criteria""" # buttons #we dont update atm because of memory leak #self.parentapp.updateAll(d)
self