Changeset 277257f in sasview for src/sas/sasgui/perspectives/fitting


Ignore:
Timestamp:
Jul 5, 2017 3:28:55 PM (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:
1386b2f
Parents:
251ef684
Message:

clean up plugin-model handling code; preserve active parameter values when plugin is updated

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

Legend:

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

    r65f3930 r277257f  
    504504        self.state.manager = manager 
    505505 
    506     def populate_box(self, model_dict): 
     506    def populate_box(self, model_list_box): 
    507507        """ 
    508508        Store list of model 
    509509 
    510         :param model_dict: dictionary containing list of models 
    511  
    512         """ 
    513         self.model_list_box = model_dict 
    514         self.state.model_list_box = self.model_list_box 
     510        :param model_list_box: dictionary containing categorized models 
     511        """ 
     512        self.model_list_box = model_list_box 
    515513        self.initialize_combox() 
    516514 
    517     def set_model_dictionary(self, model_dict): 
     515    def set_model_dictionary(self, model_dictionary): 
    518516        """ 
    519517        Store a dictionary linking model name -> model object 
    520518 
    521         :param model_dict: dictionary containing list of models 
    522         """ 
    523         self.model_dict = model_dict 
     519        :param model_dictionary: dictionary containing all models 
     520        """ 
     521        self.model_dictionary = model_dictionary 
    524522 
    525523    def initialize_combox(self): 
     
    527525        put default value in the combo box 
    528526        """ 
    529         if self.model_list_box is not None and len(self.model_list_box) > 0: 
     527        if self.model_list_box: 
    530528            self._populate_box(self.structurebox, 
    531529                               self.model_list_box["Structure Factors"]) 
     
    12181216        self.categorybox.Select(category_pos) 
    12191217        self._show_combox(None) 
    1220         if self.categorybox.GetValue() == CUSTOM_MODEL \ 
    1221                 and PLUGIN_NAME_BASE not in state.formfactorcombobox: 
     1218        if (self.categorybox.GetValue() == CUSTOM_MODEL 
     1219                and PLUGIN_NAME_BASE not in state.formfactorcombobox): 
    12221220            state.formfactorcombobox = \ 
    12231221                PLUGIN_NAME_BASE + state.formfactorcombobox 
    12241222        formfactor_pos = 0 
    12251223        for ind_form in range(self.formfactorbox.GetCount()): 
    1226             if self.formfactorbox.GetString(ind_form) == \ 
    1227                                                 (state.formfactorcombobox): 
     1224            if (self.formfactorbox.GetString(ind_form) 
     1225                    == state.formfactorcombobox): 
    12281226                formfactor_pos = int(ind_form) 
    12291227                break 
     
    12351233            state.structurecombobox = unicode(state.structurecombobox) 
    12361234            for ind_struct in range(self.structurebox.GetCount()): 
    1237                 if self.structurebox.GetString(ind_struct) == \ 
    1238                                                 (state.structurecombobox): 
     1235                if (self.structurebox.GetString(ind_struct) 
     1236                        == state.structurecombobox): 
    12391237                    structfactor_pos = int(ind_struct) 
    12401238                    break 
     
    18401838            if mod_cat == CUSTOM_MODEL: 
    18411839                for model in self.model_list_box[mod_cat]: 
    1842                     m_list.append(self.model_dict[model.name]) 
     1840                    m_list.append(self.model_dictionary[model.name]) 
    18431841            else: 
    18441842                cat_dic = self.master_category_dict[mod_cat] 
    1845                 for (model, enabled) in cat_dic: 
     1843                for model, enabled in cat_dic: 
    18461844                    if enabled: 
    1847                         m_list.append(self.model_dict[model]) 
     1845                        m_list.append(self.model_dictionary[model]) 
    18481846        except Exception: 
    18491847            msg = traceback.format_exc() 
     
    34973495        self.model_box.Clear() 
    34983496 
    3499         if category == 'Plugin Models': 
     3497        if category == CUSTOM_MODEL: 
    35003498            for model in self.model_list_box[category]: 
    35013499                str_m = str(model).split(".")[0] 
  • src/sas/sasgui/perspectives/fitting/fitpage.py

    r50fcb09 r277257f  
    11431143            self.model.name = "M" + str(self.index_model) 
    11441144 
    1145     def _on_select_model(self, event=None): 
     1145    def _on_select_model(self, event=None, keep_pars=False): 
    11461146        """ 
    11471147        call back for model selection 
    11481148        """ 
    11491149        self.Show(False) 
    1150         copy_flag = False 
    1151         is_poly_enabled = None 
    11521150        if event is not None: 
    1153             if (event.GetEventObject() == self.formfactorbox 
    1154                     and self.structurebox.GetLabel() != 'None')\ 
    1155                     or event.GetEventObject() == self.structurebox\ 
    1156                     or event.GetEventObject() == self.multifactorbox: 
    1157                 copy_flag = self.get_copy_params() 
    1158                 is_poly_enabled = self.enable_disp.GetValue() 
     1151            control = event.GetEventObject() 
     1152            if ((control == self.formfactorbox 
     1153                 and self.structurebox.GetLabel() != 'None') 
     1154                    or control == self.structurebox 
     1155                    or control == self.multifactorbox): 
     1156                keep_pars = True 
     1157 
     1158        if keep_pars: 
     1159            saved_pars = self.get_copy_params() 
     1160            is_poly_enabled = self.enable_disp.GetValue() 
     1161        else: 
     1162            saved_pars = None 
     1163            is_poly_enabled = None 
    11591164 
    11601165        self._on_select_model_helper() 
     
    11711176        try: 
    11721177            self.set_dispers_sizer() 
    1173         except: 
     1178        except Exception: 
    11741179            pass 
    11751180        self.state.enable_disp = self.enable_disp.GetValue() 
     
    12321237            self.state.model.name = self.model.name 
    12331238 
     1239        # when select a model only from guictr/button 
     1240        if is_poly_enabled is not None: 
     1241            self.enable_disp.SetValue(is_poly_enabled) 
     1242            self.disable_disp.SetValue(not is_poly_enabled) 
     1243            self._set_dipers_Param(event=None) 
     1244            self.state.enable_disp = self.enable_disp.GetValue() 
     1245            self.state.disable_disp = self.disable_disp.GetValue() 
     1246 
     1247        # Keep the previous param values 
     1248        if saved_pars: 
     1249            self.get_paste_params(saved_pars) 
     1250 
    12341251        if event is not None: 
     1252            # update list of plugins if new plugin is available 
     1253            # mod_cat = self.categorybox.GetStringSelection() 
     1254            # if mod_cat == CUSTOM_MODEL: 
     1255            #     temp = self.parent.update_model_list() 
     1256            #     if temp: 
     1257            #         self.model_list_box = temp 
     1258            #         current_val = self.formfactorbox.GetLabel() 
     1259            #         pos = self.formfactorbox.GetSelection() 
     1260            #         self._show_combox_helper() 
     1261            #         self.formfactorbox.SetStringSelection(current_val) 
     1262            #         self.formfactorbox.SetValue(current_val) 
    12351263            # post state to fit panel 
    12361264            new_event = PageInfoEvent(page=self) 
    12371265            wx.PostEvent(self.parent, new_event) 
    1238             # update list of plugins if new plugin is available 
    1239             custom_model = CUSTOM_MODEL 
    1240             mod_cat = self.categorybox.GetStringSelection() 
    1241             if mod_cat == custom_model: 
    1242                 temp = self.parent.update_model_list() 
    1243                 if temp: 
    1244                     self.model_list_box = temp 
    1245                     current_val = self.formfactorbox.GetLabel() 
    1246                     pos = self.formfactorbox.GetSelection() 
    1247                     self._show_combox_helper() 
    1248                     self.formfactorbox.SetSelection(pos) 
    1249                     self.formfactorbox.SetValue(current_val) 
    1250             # when select a model only from guictr/button 
    1251             if is_poly_enabled is not None: 
    1252                 self.enable_disp.SetValue(is_poly_enabled) 
    1253                 self.disable_disp.SetValue(not is_poly_enabled) 
    1254                 self._set_dipers_Param(event=None) 
    1255                 self.state.enable_disp = self.enable_disp.GetValue() 
    1256                 self.state.disable_disp = self.disable_disp.GetValue() 
    1257  
    1258             # Keep the previous param values 
    1259             if copy_flag: 
    1260                 self.get_paste_params(copy_flag) 
    12611266            wx.CallAfter(self._onDraw, None) 
    12621267 
     
    17091714                and not self.temp_multi_functional: 
    17101715            return None 
     1716        print("_set_fun_box_list", self.model.name) 
    17111717        # Get the func name list 
    17121718        list = self.model.fun_list 
     
    17161722        ind = 0 
    17171723        while(ind < len(list)): 
    1718             for key, val in list.iteritems(): 
    1719                 if (val == ind): 
     1724            for key, val in list.items(): 
     1725                if val == ind: 
    17201726                    fun_box.Append(key, val) 
    17211727                    break 
  • src/sas/sasgui/perspectives/fitting/fitpanel.py

    r65f3930 r277257f  
    114114        """ 
    115115        temp = self.menu_mng.update() 
    116         if len(temp): 
     116        if temp: 
    117117            self.model_list_box = temp 
    118118        return temp 
     
    121121        """ 
    122122        """ 
    123         temp = self.menu_mng.plugins_reset() 
    124         if len(temp): 
    125             self.model_list_box = temp 
    126         return temp 
     123        self.model_list_box = self.menu_mng.plugins_reset() 
     124        return self.model_list_box 
    127125 
    128126    def get_page_by_id(self, uid): 
     
    298296        self.model_list_box = dict 
    299297 
    300     def set_model_dict(self, m_dict): 
     298    def set_model_dictionary(self, model_dictionary): 
    301299        """ 
    302300        copy a dictionary of model name -> model object 
    303301 
    304         :param m_dict: dictionary linking model name -> model object 
     302        :param model_dictionary: dictionary linking model name -> model object 
    305303        """ 
    306304 
     
    356354        panel._set_save_flag(not panel.batch_on) 
    357355        panel.set_model_dictionary(self.model_dictionary) 
    358         panel.populate_box(model_dict=self.model_list_box) 
     356        panel.populate_box(model_list_box=self.model_list_box) 
    359357        panel.formfactor_combo_init() 
    360358        panel.set_manager(self._manager) 
  • src/sas/sasgui/perspectives/fitting/fitting.py

    r00f7ff1 r277257f  
    3434from sas.sascalc.fit.BumpsFitting import BumpsFit as Fit 
    3535from sas.sascalc.fit.pagestate import Reader, PageState, SimFitPageState 
     36from sas.sascalc.fit import models 
    3637 
    3738from sas.sasgui.guiframe.dataFitting import Data2D 
     
    6061from .resultpanel import ResultPanel, PlotResultEvent 
    6162from .gpu_options import GpuOptions 
    62 from . import models 
    6363 
    6464logger = logging.getLogger(__name__) 
     
    297297        event_id = event.GetId() 
    298298        model_manager = models.ModelManager() 
    299         model_list = model_manager.get_model_name_list() 
     299        model_list = model_manager.composable_models() 
    300300        plug_dir = models.find_plugins_dir() 
    301301        textdial = TextDialog(None, self, wx.ID_ANY, 'Easy Sum/Multi(p1, p2) Editor', 
     
    337337            self.set_edit_menu_helper(self.parent, self.edit_custom_model) 
    338338            self.set_edit_menu_helper(self.parent, self.delete_custom_model) 
    339             temp = self.fit_panel.reset_pmodel_list() 
    340             if temp: 
    341                 # Set the new plugin model list for all fit pages 
    342                 for uid, page in self.fit_panel.opened_pages.iteritems(): 
    343                     if hasattr(page, "formfactorbox"): 
    344                         page.model_list_box = temp 
    345                         current_val = page.formfactorbox.GetLabel() 
    346                         #if page.plugin_rbutton.GetValue(): 
    347                         mod_cat = page.categorybox.GetStringSelection() 
    348                         if mod_cat == custom_model: 
    349                             #pos = page.formfactorbox.GetSelection() 
    350                             page._show_combox_helper() 
    351                             new_val = page.formfactorbox.GetLabel() 
    352                             if current_val != new_val and new_val != '': 
    353                                 page.formfactorbox.SetLabel(new_val) 
    354                             else: 
    355                                 page.formfactorbox.SetLabel(current_val) 
    356         except: 
     339            new_pmodel_list = self.fit_panel.reset_pmodel_list() 
     340            if not new_pmodel_list: 
     341                return 
     342            # Set the new plugin model list for all fit pages 
     343            for uid, page in self.fit_panel.opened_pages.iteritems(): 
     344                if hasattr(page, "formfactorbox"): 
     345                    page.model_list_box = new_pmodel_list 
     346                    mod_cat = page.categorybox.GetStringSelection() 
     347                    if mod_cat == custom_model: 
     348                        box = page.formfactorbox 
     349                        model_name = box.GetValue() 
     350                        model = (box.GetClientData(box.GetCurrentSelection()) 
     351                                 if model_name else None) 
     352                        page._show_combox_helper() 
     353                        new_index = box.FindString(model_name) 
     354                        new_model = (box.GetClientData(new_index) 
     355                                     if new_index >= 0 else None) 
     356                        if new_index >= 0: 
     357                            box.SetStringSelection(model_name) 
     358                        else: 
     359                            box.SetStringSelection('') 
     360                        if model and new_model != model: 
     361                            page._on_select_model(keep_pars=True) 
     362        except Exception: 
    357363            logger.error("update_custom_combo: %s", sys.exc_value) 
    358364 
     
    364370        #new_model_menu = wx.Menu() 
    365371        self.edit_model_menu.Append(wx_id, 'New Plugin Model', 
    366                                    'Add a new model function') 
     372                                    'Add a new model function') 
    367373        wx.EVT_MENU(owner, wx_id, self.make_new_model) 
    368374 
     
    646652                self.parent.add_data(data_list={data.id: data}) 
    647653                wx.PostEvent(self.parent, NewPlotEvent(plot=data, 
    648                                         title=data.title)) 
     654                             title=data.title)) 
    649655                #need to be fix later make sure we are sendind guiframe.data 
    650656                #to panel 
     
    657663                self.parent.add_data(data_list={data.id: data}) 
    658664                wx.PostEvent(self.parent, NewPlotEvent(plot=data, 
    659                                         title=data.title)) 
     665                             title=data.title)) 
    660666                page = self.add_fit_page([data]) 
    661667                caption = page.window_caption 
    662668                self.store_data(uid=page.uid, data_list=page.get_data_list(), 
    663                         caption=caption) 
     669                                caption=caption) 
    664670                self.mypanels.append(page) 
    665671 
     
    778784        """ 
    779785        if item.find(".") >= 0: 
    780             param_names = re.split("\.", item) 
     786            param_names = re.split(r"\.", item) 
    781787            model_name = param_names[0] 
    782788            ##Assume max len is 3; eg., M0.radius.width 
     
    881887 
    882888            self.draw_model(model=model, data=data, page_id=uid, smearer=smear, 
    883                 enable1D=enable1D, enable2D=enable2D, 
    884                 qmin=qmin, qmax=qmax, weight=weight) 
     889                            enable1D=enable1D, enable2D=enable2D, 
     890                            qmin=qmin, qmax=qmax, weight=weight) 
    885891 
    886892    def draw_model(self, model, page_id, data=None, smearer=None, 
     
    925931            ## draw model 2D with no initial data 
    926932            self._draw_model2D(model=model, 
    927                                 page_id=page_id, 
    928                                 data=data, 
    929                                 enable2D=enable2D, 
    930                                 smearer=smearer, 
    931                                 qmin=qmin, 
    932                                 qmax=qmax, 
    933                                 fid=fid, 
    934                                 weight=weight, 
    935                                 state=state, 
    936                                 toggle_mode_on=toggle_mode_on, 
    937                                 update_chisqr=update_chisqr, 
    938                                 source=source) 
     933                               page_id=page_id, 
     934                               data=data, 
     935                               enable2D=enable2D, 
     936                               smearer=smearer, 
     937                               qmin=qmin, 
     938                               qmax=qmax, 
     939                               fid=fid, 
     940                               weight=weight, 
     941                               state=state, 
     942                               toggle_mode_on=toggle_mode_on, 
     943                               update_chisqr=update_chisqr, 
     944                               source=source) 
    939945 
    940946    def onFit(self, uid): 
     
    945951        :param uid: id related to the panel currently calling this fit function. 
    946952        """ 
    947         if uid is None: raise RuntimeError("no page to fit") # Should never happen 
     953        if uid is None: 
     954            raise RuntimeError("no page to fit") # Should never happen 
    948955 
    949956        sim_page_uid = getattr(self.sim_page, 'uid', None) 
     
    979986                    page = self.fit_panel.get_page_by_id(page_id) 
    980987                    self.set_fit_weight(uid=page.uid, 
    981                                      flag=page.get_weight_flag(), 
    982                                      is2d=page._is_2D()) 
     988                                        flag=page.get_weight_flag(), 
     989                                        is2d=page._is_2D()) 
    983990                    if not page.param_toFit: 
    984991                        msg = "No fitting parameters for %s" % page.window_caption 
     
    10041011                            fitter = sim_fitter 
    10051012                        self._add_problem_to_fit(fitproblem=fitproblem, 
    1006                                              pars=pars, 
    1007                                              fitter=fitter, 
    1008                                              fit_id=fit_id) 
     1013                                                 pars=pars, 
     1014                                                 fitter=fitter, 
     1015                                                 fit_id=fit_id) 
    10091016                        fit_id += 1 
    10101017                    list_page_id.append(page_id) 
     
    10531060            ## Perform more than 1 fit at the time 
    10541061            calc_fit = FitThread(handler=handler, 
    1055                                     fn=fitter_list, 
    1056                                     batch_inputs=batch_inputs, 
    1057                                     batch_outputs=batch_outputs, 
    1058                                     page_id=list_page_id, 
    1059                                     updatefn=handler.update_fit, 
    1060                                     completefn=self._fit_completed) 
     1062                                 fn=fitter_list, 
     1063                                 batch_inputs=batch_inputs, 
     1064                                 batch_outputs=batch_outputs, 
     1065                                 page_id=list_page_id, 
     1066                                 updatefn=handler.update_fit, 
     1067                                 completefn=self._fit_completed) 
    10611068        #self.fit_thread_list[current_page_id] = calc_fit 
    10621069        self.fit_thread_list[uid] = calc_fit 
     
    11191126                evt = StatusEvent(status=msg, info="warning") 
    11201127                wx.PostEvent(self.parent, evt) 
    1121         except: 
     1128        except Exception: 
    11221129            msg = "Creating Fit page: %s" % sys.exc_value 
    11231130            wx.PostEvent(self.parent, StatusEvent(status=msg, info="error")) 
     
    11431150                    group_id = str(page.uid) + " Model1D" 
    11441151                    wx.PostEvent(self.parent, 
    1145                              NewPlotEvent(group_id=group_id, 
    1146                                                action="delete")) 
     1152                                 NewPlotEvent(group_id=group_id, 
     1153                                              action="delete")) 
    11471154                    self.parent.update_data(prev_data=theory_data, 
    1148                                              new_data=data) 
     1155                                            new_data=data) 
    11491156            else: 
    11501157                if theory_data is not None: 
     
    11521159                    data.group_id = theory_data.group_id 
    11531160                    wx.PostEvent(self.parent, 
    1154                              NewPlotEvent(group_id=group_id, 
    1155                                                action="delete")) 
     1161                                 NewPlotEvent(group_id=group_id, 
     1162                                              action="delete")) 
    11561163                    self.parent.update_data(prev_data=theory_data, 
    1157                                              new_data=data) 
     1164                                            new_data=data) 
    11581165        self.store_data(uid=page.uid, data_list=page.get_data_list(), 
    11591166                        caption=page.window_caption) 
     
    15571564                    except KeyboardInterrupt: 
    15581565                        fit_msg += "\nSingular point: Fitting stopped." 
    1559                     except: 
     1566                    except Exception: 
    15601567                        fit_msg += "\nSingular point: Fitting error occurred." 
    15611568                if fit_msg: 
    1562                    evt = StatusEvent(status=fit_msg, info="warning", type="stop") 
    1563                    wx.PostEvent(self.parent, evt) 
    1564  
    1565         except: 
     1569                    evt = StatusEvent(status=fit_msg, info="warning", type="stop") 
     1570                    wx.PostEvent(self.parent, evt) 
     1571 
     1572        except Exception: 
    15661573            msg = ("Fit completed but the following error occurred: %s" 
    15671574                   % sys.exc_value) 
     
    17211728                                                  fid=data.id) 
    17221729        self.parent.update_theory(data_id=data.id, theory=new_plot, 
    1723                                    state=state) 
     1730                                  state=state) 
    17241731        return new_plot 
    17251732 
     
    17751782 
    17761783        self.page_finder[page_id].set_theory_data(data=new_plot, 
    1777                                                       fid=data.id) 
     1784                                                  fid=data.id) 
    17781785        if toggle_mode_on: 
    17791786            wx.PostEvent(self.parent, 
    17801787                         NewPlotEvent(group_id=str(page_id) + " Model2D", 
    1781                                           action="Hide")) 
     1788                                      action="Hide")) 
    17821789        else: 
    17831790            if update_chisqr: 
    1784                 wx.PostEvent(current_pg, 
    1785                              Chi2UpdateEvent(output=self._cal_chisqr( 
    1786                                                                 data=data, 
    1787                                                                 fid=fid, 
    1788                                                                 weight=weight, 
    1789                                                                 page_id=page_id, 
    1790                                                                 index=index))) 
     1791                output = self._cal_chisqr(data=data, 
     1792                                          fid=fid, 
     1793                                          weight=weight, 
     1794                                          page_id=page_id, 
     1795                                          index=index) 
     1796                wx.PostEvent(current_pg, Chi2UpdateEvent(output=output)) 
    17911797            else: 
    17921798                self._plot_residuals(page_id=page_id, data=data, fid=fid, 
     
    17961802            logger.error("Using the present parameters the model does not return any finite value. ") 
    17971803            msg = "Computing Error: Model did not return any finite value." 
    1798             wx.PostEvent(self.parent, StatusEvent(status = msg, info="error")) 
     1804            wx.PostEvent(self.parent, StatusEvent(status=msg, info="error")) 
    17991805        else: 
    18001806            msg = "Computation  completed!" 
     
    18211827 
    18221828    def _complete2D(self, image, data, model, page_id, elapsed, index, qmin, 
    1823                 qmax, fid=None, weight=None, toggle_mode_on=False, state=None, 
    1824                      update_chisqr=True, source='model', plot_result=True): 
     1829                    qmax, fid=None, weight=None, toggle_mode_on=False, state=None, 
     1830                    update_chisqr=True, source='model', plot_result=True): 
    18251831        """ 
    18261832        Complete get the result of modelthread and create model 2D 
     
    18631869                                                  fid=data.id) 
    18641870        self.parent.update_theory(data_id=data.id, 
    1865                                        theory=new_plot, 
    1866                                        state=state) 
     1871                                  theory=new_plot, 
     1872                                  state=state) 
    18671873        current_pg = self.fit_panel.get_page_by_id(page_id) 
    18681874        title = new_plot.title 
    18691875        if not source == 'fit' and plot_result: 
    1870             wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, 
    1871                                                title=title)) 
     1876            wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title=title)) 
    18721877        if toggle_mode_on: 
    18731878            wx.PostEvent(self.parent, 
    1874                              NewPlotEvent(group_id=str(page_id) + " Model1D", 
    1875                                                action="Hide")) 
     1879                         NewPlotEvent(group_id=str(page_id) + " Model1D", 
     1880                                      action="Hide")) 
    18761881        else: 
    18771882            # Chisqr in fitpage 
    18781883            if update_chisqr: 
    1879                 wx.PostEvent(current_pg, 
    1880                              Chi2UpdateEvent(output=self._cal_chisqr(data=data, 
    1881                                                                     weight=weight, 
    1882                                                                     fid=fid, 
    1883                                                          page_id=page_id, 
    1884                                                          index=index))) 
     1884                output = self._cal_chisqr(data=data, 
     1885                                          weight=weight, 
     1886                                          fid=fid, 
     1887                                          page_id=page_id, 
     1888                                          index=index) 
     1889                wx.PostEvent(current_pg, Chi2UpdateEvent(output=output)) 
    18851890            else: 
    18861891                self._plot_residuals(page_id=page_id, data=data, fid=fid, 
    1887                                       index=index, weight=weight) 
     1892                                     index=index, weight=weight) 
    18881893 
    18891894        if not number_finite: 
    18901895            logger.error("Using the present parameters the model does not return any finite value. ") 
    18911896            msg = "Computing Error: Model did not return any finite value." 
    1892             wx.PostEvent(self.parent, StatusEvent(status = msg, info="error")) 
     1897            wx.PostEvent(self.parent, StatusEvent(status=msg, info="error")) 
    18931898        else: 
    18941899            msg = "Computation  completed!" 
     
    19061911                      weight=None, 
    19071912                      toggle_mode_on=False, 
    1908                        update_chisqr=True, source='model'): 
     1913                      update_chisqr=True, source='model'): 
    19091914        """ 
    19101915        draw model in 2D 
     
    19521957    def _draw_model1D(self, model, page_id, data, 
    19531958                      qmin, qmax, smearer=None, 
    1954                 state=None, 
    1955                 weight=None, 
    1956                 fid=None, 
    1957                 toggle_mode_on=False, update_chisqr=True, source='model', 
    1958                 enable1D=True): 
     1959                      state=None, weight=None, fid=None, 
     1960                      toggle_mode_on=False, update_chisqr=True, source='model', 
     1961                      enable1D=True): 
    19591962        """ 
    19601963        Draw model 1D from loaded data1D 
Note: See TracChangeset for help on using the changeset viewer.