Changeset e6de6b8 in sasview for src/sas/sasgui/perspectives/fitting


Ignore:
Timestamp:
Oct 7, 2016 4:03:49 PM (8 years ago)
Author:
krzywon
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
95eef00
Parents:
ff3f5821
Message:

Delinting and small structural changes.

Location:
src/sas/sasgui/perspectives/fitting
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/fitting/fitpanel.py

    r998ca90 re6de6b8  
    1010 
    1111from sas.sasgui.guiframe.panel_base import PanelBase 
    12 from sas.sasgui.guiframe.events import PanelOnFocusEvent 
    13 from sas.sasgui.guiframe.events import StatusEvent 
     12from sas.sasgui.guiframe.events import PanelOnFocusEvent, StatusEvent 
    1413from sas.sasgui.guiframe.dataFitting import check_data_validity 
    1514from sas.sasgui.perspectives.fitting.simfitpage import SimultaneousFitPage 
     
    176175    def get_state(self): 
    177176        """ 
    178          return the state of the current selected page 
     177        return the state of the current selected page 
    179178        """ 
    180179        pos = self.GetSelection() 
     
    188187        """ 
    189188 
    190         #get number of pages 
     189        # get number of pages 
    191190        nop = self.GetPageCount() 
    192         #use while-loop, for-loop will not do the job well. 
     191        # use while-loop, for-loop will not do the job well. 
    193192        while (nop > 0): 
    194             #delete the first page until no page exists 
     193            # delete the first page until no page exists 
    195194            page = self.GetPage(0) 
    196195            if self._manager.parent.panel_on_focus == page: 
     
    198197            self._close_helper(selected_page=page) 
    199198            self.DeletePage(0) 
    200             nop = nop - 1 
    201  
    202         # save the title of the last page tab added 
     199            nop = self.GetPageCount() 
     200        # Clear list of names 
    203201        self.fit_page_name = {} 
    204         # list of existing fit page 
     202        # Clear list of opened pages 
    205203        self.opened_pages = {} 
    206204        self.fit_page_index = 0 
     
    214212        if state is not None: 
    215213            for uid, panel in self.opened_pages.iteritems(): 
    216                 #Don't return any panel is the exact same page is created 
     214                # Don't return any panel is the exact same page is created 
    217215                if uid == panel.uid and panel.data == state.data: 
    218216                    # the page is still opened 
     
    222220            if not page_is_opened: 
    223221                if state.data.__class__.__name__ != 'list': 
    224                     #To support older state file format 
     222                    # To support older state file format 
    225223                    list_data = [state.data] 
    226224                else: 
    227                     #Todo: need new file format for the list 
     225                    # Todo: need new file format for the list 
    228226                    list_data = state.data 
    229227                panel = self._manager.add_fit_page(data=list_data) 
     
    240238        Clear and close all panels, used by guimanager 
    241239        """ 
    242  
    243         #close all panels only when svs file opened 
     240        # close all panels only when svs file opened 
    244241        self.close_all() 
    245242        self._manager.mypanels = [] 
     
    254251        selected_page = self.GetPage(self.GetSelection()) 
    255252        if nbr_page == 1: 
    256             if selected_page.get_data() == None: 
     253            if selected_page.get_data() is not None: 
    257254                if event is not None: 
    258255                    event.Veto() 
     
    272269 
    273270                if data is None: 
    274                     #the fitpanel exists and only the initial fit page is open 
    275                     #with no selected data 
     271                    # the fitpanel exists and only the initial fit page is open 
     272                    # with no selected data 
    276273                    return 
    277274                if data.id == deleted_data.id: 
     
    285282 
    286283        :param manager: instance of plugin fitting 
    287  
    288284        """ 
    289285        self._manager = manager 
     
    334330        else: 
    335331            self.batch_page = SimultaneousFitPage(self, batch_on=True, 
    336                                                    page_finder=page_finder) 
     332                                                  page_finder=page_finder) 
    337333            self.batch_page.window_caption = caption 
    338334            self.batch_page.window_name = caption 
     
    347343        add an empty page 
    348344        """ 
    349         """ 
    350345        if self.batch_on: 
    351346            from batchfitpage import BatchFitPage 
    352             panel = BatchFitPage(parent=self) 
    353             #Increment index of batch page 
    354             self.batch_page_index += 1 
    355             index = self.batch_page_index 
    356         else: 
    357         """ 
    358         from fitpage import FitPage 
    359         from batchfitpage import BatchFitPage 
    360         if self.batch_on: 
    361347            panel = BatchFitPage(parent=self) 
    362348            self.batch_page_index += 1 
     
    365351        else: 
    366352            # Increment index of fit page 
     353            from fitpage import FitPage 
    367354            panel = FitPage(parent=self) 
    368355            self.fit_page_index += 1 
     
    442429        page = None 
    443430        for p in self.opened_pages.values(): 
    444             #check if there is an empty page to fill up 
     431            # check if there is an empty page to fill up 
    445432            if not check_data_validity(p.get_data()) and p.batch_on: 
    446433 
    447                 #make sure data get placed in 1D empty tab if data is 1D 
    448                 #else data get place on 2D tab empty tab 
     434                # make sure data get placed in 1D empty tab if data is 1D 
     435                # else data get place on 2D tab empty tab 
    449436                enable2D = p.get_view_mode() 
    450437                if (data.__class__.__name__ == "Data2D" and enable2D)\ 
     
    459446                data_type = dlg.get_data() 
    460447                dlg.Destroy() 
    461                 if page  is None: 
     448                if page is None: 
    462449                    page = self.add_empty_page() 
    463450                if data_type == 1: 
    464                     #user has selected only data1D 
     451                    # user has selected only data1D 
    465452                    page.fill_data_combobox(data_1d_list) 
    466453                elif data_type == 2: 
    467454                    page.fill_data_combobox(data_2d_list) 
    468455            else: 
    469                 #the batch analysis is canceled 
     456                # the batch analysis is canceled 
    470457                dlg.Destroy() 
    471458                return None 
     
    504491            try: 
    505492                data = data_list[0] 
    506             except: 
     493            except Exception: 
    507494                # for 'fitv' files 
    508495                data_list = [data] 
     
    512499                return None 
    513500        for page in self.opened_pages.values(): 
    514             #check if the selected data existing in the fitpanel 
     501            # check if the selected data existing in the fitpanel 
    515502            pos = self.GetPageIndex(page) 
    516503            if not check_data_validity(page.get_data()) and not page.batch_on: 
    517                 #make sure data get placed in 1D empty tab if data is 1D 
    518                 #else data get place on 2D tab empty tab 
     504                # make sure data get placed in 1D empty tab if data is 1D 
     505                # else data get place on 2D tab empty tab 
    519506                enable2D = page.get_view_mode() 
    520507                if (data.__class__.__name__ == "Data2D" and enable2D)\ 
    521                 or (data.__class__.__name__ == "Data1D" and not enable2D): 
     508                   or (data.__class__.__name__ == "Data1D" and not enable2D): 
    522509                    page.batch_on = self.batch_on 
    523510                    page._set_save_flag(not page.batch_on) 
    524511                    page.fill_data_combobox(data_list) 
    525                     #caption = "FitPage" + str(self.fit_page_index) 
     512                    # caption = "FitPage" + str(self.fit_page_index) 
    526513                    self.SetPageText(pos, page.window_caption) 
    527514                    self.SetSelection(pos) 
     
    575562        Delete the given page from the notebook 
    576563        """ 
    577         #remove hint page 
    578         #if selected_page == self.hint_page: 
     564        # remove hint page 
     565        # if selected_page == self.hint_page: 
    579566        #    return 
    580         ## removing sim_page 
     567        # removing sim_page 
    581568        if selected_page == self.sim_page: 
    582569            self._manager.sim_page = None 
     
    585572            self._manager.batch_page = None 
    586573            return 
    587         """ 
    588         # The below is not working when delete #5 and still have #6. 
    589         if selected_page.__class__.__name__ == "FitPage": 
    590             self.fit_page_index -= 1 
    591         else: 
    592             self.batch_page_index -= 1 
    593         """ 
    594         ## closing other pages 
     574        # closing other pages 
    595575        state = selected_page.createMemento() 
    596576        page_finder = self._manager.get_page_finder() 
    597         ## removing fit page 
     577        # removing fit page 
    598578        data = selected_page.get_data() 
    599         #Don' t remove plot for 2D 
     579        # Don' t remove plot for 2D 
    600580        flag = True 
    601581        if data.__class__.__name__ == 'Data2D': 
    602582            flag = False 
    603583        if selected_page in page_finder: 
    604             #Delete the name of the page into the list of open page 
     584            # Delete the name of the page into the list of open page 
    605585            for uid, list in self.opened_pages.iteritems(): 
    606                 #Don't return any panel is the exact same page is created 
    607  
     586                # Don't return any panel is the exact same page is created 
    608587                if flag and selected_page.uid == uid: 
    609588                    self._manager.remove_plot(uid, theory=False) 
     
    611590            del page_finder[selected_page] 
    612591 
    613         #Delete the name of the page into the list of open page 
     592        # Delete the name of the page into the list of open page 
    614593        for uid, list in self.opened_pages.iteritems(): 
    615             #Don't return any panel is the exact same page is created 
     594            # Don't return any panel is the exact same page is created 
    616595            if selected_page.uid == uid: 
    617596                del self.opened_pages[selected_page.uid] 
    618597                break 
    619         ##remove the check box link to the model name of this page (selected_page) 
     598        # remove the check box link to the model name of the selected_page 
    620599        try: 
    621600            self.sim_page.draw_page() 
    622601        except: 
    623             ## that page is already deleted no need to remove check box on 
    624             ##non existing page 
     602            # that page is already deleted no need to remove check box on 
     603            # non existing page 
    625604            pass 
    626605        try: 
    627606            self.batch_page.draw_page() 
    628607        except: 
    629             ## that page is already deleted no need to remove check box on 
    630             ##non existing page 
     608            # that page is already deleted no need to remove check box on 
     609            # non existing page 
    631610            pass 
  • src/sas/sasgui/perspectives/fitting/pagestate.py

    r998ca90 re6de6b8  
    16401640                            raise 
    16411641                        fitstate = self._parse_state(entry) 
    1642                         simfitstate = self._parse_simfit_state(entry) 
    16431642 
    16441643                        # state could be None when .svs file is loaded 
     
    16921691                                   datainfo=output[ind], format=ext) 
    16931692                    self.state = state 
     1693                simfitstate = self._parse_simfit_state(entry) 
    16941694                if simfitstate is not None: 
    16951695                    self.call_back(state=simfitstate) 
Note: See TracChangeset for help on using the changeset viewer.