Changeset 09ca97f in sasview for src/sas/sasgui/perspectives/fitting


Ignore:
Timestamp:
Apr 16, 2017 8:58:53 AM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
cc0948c
Parents:
be7264f1 (diff), e5cbbce (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into ticket-869

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

Legend:

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

    ree4b3cb r7432acb  
    200200#         self.state.formfactorcombobox = self.formfactorbox.GetCurrentSelection() 
    201201#        
    202 #         if self.model != None: 
     202#         if self.model is not None: 
    203203#             self._set_copy_flag(True) 
    204204#             self._set_paste_flag(True) 
    205 #             if self.data != None: 
     205#             if self.data is not None: 
    206206#                 self._set_bookmark_flag(False) 
    207207#                 self._keep.Enable(False) 
     
    225225#  
    226226#              
    227 #         if event != None: 
     227#         if event is not None: 
    228228#             ## post state to fit panel 
    229229#             new_event = PageInfoEvent(page = self) 
     
    254254#         is_modified = False 
    255255#  
    256 #         if self.model != None:            
     256#         if self.model is not None: 
    257257#             ##Check the values 
    258258#             self._check_value_enter( self.fittable_param) 
     
    291291#         else: 
    292292#             #self.btFit.Enable(True) 
    293 #             if self._is_2D() and  self.data != None: 
     293#             if self._is_2D() and  self.data is not None: 
    294294#                 self.btEditMask.Enable(True) 
    295295#  
     
    335335#             self._set_save_flag(False) 
    336336#         else: 
    337 #             if self.model != None: 
     337#             if self.model is not None: 
    338338#                 self._set_bookmark_flag(False) 
    339339#                 self._keep.Enable(False) 
  • src/sas/sasgui/perspectives/fitting/fitting.py

    r9c0f3c17 r7432acb  
    302302        Make new model 
    303303        """ 
    304         if self.new_model_frame != None: 
     304        if self.new_model_frame is not None: 
    305305            self.new_model_frame.Show(False) 
    306306            self.new_model_frame.Show(True) 
     
    386386        help for setting list of the edit model menu labels 
    387387        """ 
    388         if menu == None: 
     388        if menu is None: 
    389389            menu = self.edit_custom_model 
    390390        list_fnames = os.listdir(models.find_plugins_dir()) 
     
    441441            wx.PostEvent(self.parent, StatusEvent(status=msg)) 
    442442 
    443         if page != None: 
     443        if page is not None: 
    444444            return set_focus_page(page) 
    445445        if caption == "Const & Simul Fit": 
     
    634634            state = self.temp_state[self.state_index] 
    635635            #panel state should have model selection to set_state 
    636             if state.formfactorcombobox != None: 
     636            if state.formfactorcombobox is not None: 
    637637                #set state 
    638638                data = self.parent.create_gui_data(state.data) 
     
    10161016                return False 
    10171017        ## If a thread is already started, stop it 
    1018         #if self.calc_fit!= None and self.calc_fit.isrunning(): 
     1018        #if self.calc_fitis not None and self.calc_fit.isrunning(): 
    10191019        #    self.calc_fit.stop() 
    10201020        msg = "Fitting is in progress..." 
     
    11061106            page = self.fit_panel.add_empty_page() 
    11071107            # add data associated to the page created 
    1108             if page != None: 
     1108            if page is not None: 
    11091109                evt = StatusEvent(status="Page Created", info="info") 
    11101110                wx.PostEvent(self.parent, evt) 
     
    11251125        page = self.fit_panel.set_data(data) 
    11261126        # page could be None when loading state files 
    1127         if page == None: 
     1127        if page is None: 
    11281128            return page 
    11291129        #append Data1D to the panel containing its theory 
     
    11931193        """ 
    11941194        # case that uid is not specified 
    1195         if uid == None: 
     1195        if uid is None: 
    11961196            for page_id in self.page_finder.keys(): 
    11971197                self.page_finder[page_id].schedule_tofit(value) 
     
    12161216            for item in param: 
    12171217                ## check if constraint 
    1218                 if item[0] != None and item[1] != None: 
     1218                if item[0] is not None and item[1] is not None: 
    12191219                    listOfConstraint.append((item[0], item[1])) 
    12201220        new_model = model 
     
    12311231        """ 
    12321232        panel = self.plot_panel 
    1233         if panel == None: 
     1233        if panel is None: 
    12341234            raise ValueError, "Fitting:_onSelect: NonType panel" 
    12351235        Plugin.on_perspective(self, event=event) 
     
    13351335                if not correct_result or res.fitness is None or \ 
    13361336                    not np.isfinite(res.fitness) or \ 
    1337                         np.any(res.pvec == None) or not \ 
     1337                        np.any(res.pvec is None) or not \ 
    13381338                        np.all(np.isfinite(res.pvec)): 
    13391339                    data_name = str(None) 
     
    14571457        cell.value = index 
    14581458 
    1459         if theory_data != None: 
     1459        if theory_data is not None: 
    14601460            #Suucessful fit 
    14611461            theory_data.id = wx.NewId() 
     
    15261526                if res.fitness is None or \ 
    15271527                    not np.isfinite(res.fitness) or \ 
    1528                         np.any(res.pvec == None) or \ 
     1528                        np.any(res.pvec is None) or \ 
    15291529                    not np.all(np.isfinite(res.pvec)): 
    15301530                    fit_msg += "\nFitting did not converge!!!" 
     
    15441544                    #(CallAfter is important to MAC) 
    15451545                    try: 
    1546                         #if res != None: 
     1546                        #if res is not None: 
    15471547                        wx.CallAfter(cpage.onsetValues, res.fitness, 
    15481548                                     res.param_list, 
     
    15871587        """ 
    15881588        event.Skip() 
    1589         if self.menu1 == None: 
     1589        if self.menu1 is None: 
    15901590            return 
    15911591        menu_item = self.menu1.FindItemById(self.id_reset_flag) 
     
    16461646        caption = evt.caption 
    16471647        enable_smearer = evt.enable_smearer 
    1648         if model == None: 
     1648        if model is None: 
    16491649            return 
    16501650        if uid not in self.page_finder.keys(): 
     
    16981698        new_plot.title = data.name 
    16991699        new_plot.group_id = data.group_id 
    1700         if new_plot.group_id == None: 
     1700        if new_plot.group_id is None: 
    17011701            new_plot.group_id = data.group_id 
    17021702        new_plot.id = data_id 
     
    20022002        chisqr = None 
    20032003        #to compute chisq make sure data has valid data 
    2004         # return None if data == None 
    2005         if not check_data_validity(data_copy) or data_copy == None: 
     2004        # return None if data is None 
     2005        if not check_data_validity(data_copy) or data_copy is None: 
    20062006            return chisqr 
    20072007 
    20082008        # Get data: data I, theory I, and data dI in order 
    20092009        if data_copy.__class__.__name__ == "Data2D": 
    2010             if index == None: 
     2010            if index is None: 
    20112011                index = np.ones(len(data_copy.data), dtype=bool) 
    2012             if weight != None: 
     2012            if weight is not None: 
    20132013                data_copy.err_data = weight 
    20142014            # get rid of zero error points 
     
    20172017            fn = data_copy.data[index] 
    20182018            theory_data = self.page_finder[page_id].get_theory_data(fid=data_copy.id) 
    2019             if theory_data == None: 
     2019            if theory_data is None: 
    20202020                return chisqr 
    20212021            gn = theory_data.data[index] 
     
    20232023        else: 
    20242024            # 1 d theory from model_thread is only in the range of index 
    2025             if index == None: 
     2025            if index is None: 
    20262026                index = np.ones(len(data_copy.y), dtype=bool) 
    2027             if weight != None: 
     2027            if weight is not None: 
    20282028                data_copy.dy = weight 
    2029             if data_copy.dy == None or data_copy.dy == []: 
     2029            if data_copy.dy is None or data_copy.dy == []: 
    20302030                dy = np.ones(len(data_copy.y)) 
    20312031            else: 
     
    20372037 
    20382038            theory_data = self.page_finder[page_id].get_theory_data(fid=data_copy.id) 
    2039             if theory_data == None: 
     2039            if theory_data is None: 
    20402040                return chisqr 
    20412041            gn = theory_data.y 
     
    20802080            theory_data = self.page_finder[page_id].get_theory_data(fid=data_copy.id) 
    20812081            gn = theory_data.data 
    2082             if weight == None: 
     2082            if weight is None: 
    20832083                en = data_copy.err_data 
    20842084            else: 
     
    21012101        else: 
    21022102            # 1 d theory from model_thread is only in the range of index 
    2103             if data_copy.dy == None or data_copy.dy == []: 
     2103            if data_copy.dy is None or data_copy.dy == []: 
    21042104                dy = np.ones(len(data_copy.y)) 
    21052105            else: 
    2106                 if weight == None: 
     2106                if weight is None: 
    21072107                    dy = np.ones(len(data_copy.y)) 
    21082108                ## Set consitently w/AbstractFitengine: 
     
    21422142        ##group_id specify on which panel to plot this data 
    21432143        group_id = self.page_finder[page_id].get_graph_id() 
    2144         if group_id == None: 
     2144        if group_id is None: 
    21452145            group_id = data.group_id 
    21462146        new_plot.group_id = "res" + str(group_id) 
  • src/sas/sasgui/perspectives/fitting/model_thread.py

    r9a5097c r7432acb  
    5353        self.starttime = time.time() 
    5454        # Determine appropriate q range 
    55         if self.qmin == None: 
     55        if self.qmin is None: 
    5656            self.qmin = 0 
    57         if self.qmax == None: 
    58             if self.data != None: 
     57        if self.qmax is None: 
     58            if self.data is not None: 
    5959                newx = math.pow(max(math.fabs(self.data.xmax), 
    6060                                   math.fabs(self.data.xmin)), 2) 
  • src/sas/sasgui/perspectives/fitting/report_dialog.py

    rd85c194 r7432acb  
    3939        self.nimages = len(self.report_list[2]) 
    4040 
    41         if self.report_list[2] != None: 
     41        if self.report_list[2] is not None: 
    4242            # put image path in the report string 
    4343            if len(self.report_list[2]) == 1: 
  • src/sas/sasgui/perspectives/fitting/basepage.py

    r9c0f3c17 rbe7264f1  
    1313import traceback 
    1414 
     15from Queue import Queue 
     16from threading import Thread 
    1517from collections import defaultdict 
    1618from wx.lib.scrolledpanel import ScrolledPanel 
     
    239241        self.set_layout() 
    240242 
     243        # Setting up a thread for the fitting 
     244        self.threaded_draw_queue = Queue() 
     245 
     246        self.draw_worker_thread = Thread(target = self._threaded_draw_worker, 
     247                                         args = (self.threaded_draw_queue,)) 
     248        self.draw_worker_thread.setDaemon(True) 
     249        self.draw_worker_thread.start() 
     250 
     251        # And a home for the thread submission times 
     252        self.last_time_fit_submitted = 0.00 
     253 
    241254    def set_index_model(self, index): 
    242255        """ 
     
    16911704        :param chisqr: update chisqr value [bool] 
    16921705        """ 
    1693         wx.CallAfter(self._draw_model_after, update_chisqr, source) 
     1706        # Get the time 
     1707        current_time = time.time() 
     1708 
     1709        # When loading we slam a number of fits through here 
     1710        # let's filter these out to start with 
     1711        if current_time > (self.last_time_fit_submitted + 0.1): 
     1712            # Submitting the rest 
     1713            self.threaded_draw_queue.put([update_chisqr, source]) 
     1714        else: 
     1715            pass 
     1716 
     1717        self.last_time_fit_submitted = current_time 
     1718 
     1719    def _threaded_draw_worker(self, threaded_draw_queue): 
     1720        while True: 
     1721            # Check to see is a manager is running and a calc is running 
     1722            if ((self._manager.calc_1D is not None) and (self._manager.calc_1D.\ 
     1723                isrunning() == True)) or ((self._manager.calc_2D is not None)\ 
     1724                and (self._manager.calc_2D.isrunning() == True)): 
     1725                # If a manager is running a calculation  
     1726                # then trim the queue 
     1727                if self.threaded_draw_queue.qsize() > 1: 
     1728                    for loopIter in range(threaded_draw_queue.qsize() - 1): 
     1729                        dump = self.threaded_draw_queue.get() 
     1730                        self.threaded_draw_queue.task_done() 
     1731            else: 
     1732                # Otherwise, just run 
     1733                input_variables = threaded_draw_queue.get() 
     1734                self._draw_model_after(input_variables[0], input_variables[1]) 
     1735                wx.PostEvent(self._manager.parent, StatusEvent(status =  
     1736                            "Computation is in progress...", type = "progress")) 
     1737                threaded_draw_queue.task_done() 
    16941738 
    16951739    def _draw_model_after(self, update_chisqr=True, source='model'): 
     
    17141758            toggle_mode_on = self.model_view.IsEnabled() 
    17151759            is_2d = self._is_2D() 
     1760 
    17161761            self._manager.draw_model(self.model, 
    17171762                                     data=self.data, 
Note: See TracChangeset for help on using the changeset viewer.