Ignore:
Timestamp:
Mar 27, 2015 11:05:11 AM (9 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, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
cce0ad3
Parents:
a862cea0
Message:

Fix for ticket #395 - Saving a project now saves all fits and loading a
project no longer throws an error by trying to find deprecated fitting
engines.

File:
1 edited

Legend:

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

    r7cd87c2 r5ce7f17  
    175175        self.orientation_params = [] 
    176176        self.orientation_params_disp = [] 
    177 #       Self.model should ALWAYS be None here.  It was set to none above in  
     177#       Self.model should ALWAYS be None here.  It was set to none above in 
    178178#       this long init setting.  no obvious function call in between setting 
    179 #       and this - commenting out on 4/8/2014 by PDB.  Remove once clear  
     179#       and this - commenting out on 4/8/2014 by PDB.  Remove once clear 
    180180#       it is pointless. 
    181181#        if self.model != None: 
     
    417417        _on_set_focus_callback = None 
    418418 
    419         def __init__(self, parent, id= -1, 
     419        def __init__(self, parent, id=-1, 
    420420                     value=wx.EmptyString, 
    421421                     pos=wx.DefaultPosition, 
     
    430430 
    431431            wx.TextCtrl.__init__(self, parent, id, value, pos, 
    432                                   size, style, validator, name) 
     432                                 size, style, validator, name) 
    433433 
    434434            # Bind appropriate events 
     
    488488        set some page important information at once 
    489489        """ 
    490 #       THIS METHOD/FUNCTION NO LONGE APPEARS TO BE CALLED.  Started up program  
     490#       THIS METHOD/FUNCTION NO LONGE APPEARS TO BE CALLED.  Started up program 
    491491#       and started new fit window and PR and Invariant and a fit in fitting 
    492492#       but never entered this routine which should be an initialization 
    493 #       routine.  Leave for a while but probably something to clean up at  
     493#       routine.  Leave for a while but probably something to clean up at 
    494494#       some point? 
    495495# 
     
    589589    def get_state(self): 
    590590        """ 
     591        return the current page state 
    591592        """ 
    592593        return self.state 
     
    645646        ## These are called for first time by formfactor_combo_init 
    646647        ## itself called from fitpanel only.  If we find that I'm wrong and 
    647         ## we DO need to initialize somehow here - do it by a call to  
    648         ## formfactor_combo_init  
     648        ## we DO need to initialize somehow here - do it by a call to 
     649        ## formfactor_combo_init 
    649650        ## self.formfator_combo_init() 
    650         ## BUT NOT HERE -- make it last line of this  
     651        ## BUT NOT HERE -- make it last line of this 
    651652        ## method so that structure box is populated before _show_comboox_helper 
    652653        ## is called.  Otherwise wx will complain mightily:-) 
     
    660661#                               self.model_list_box["Shapes"]) 
    661662            self._populate_box(self.structurebox, 
    662                                 self.model_list_box["Structure Factors"]) 
     663                               self.model_list_box["Structure Factors"]) 
    663664            self.structurebox.Insert("None", 0, None) 
    664665            self.structurebox.SetSelection(0) 
     
    686687        #---------------------------------------------------- 
    687688        self.disable_disp = wx.RadioButton(self, -1, 'Off', (10, 10), 
    688                                             style=wx.RB_GROUP) 
     689                                           style=wx.RB_GROUP) 
    689690        self.enable_disp = wx.RadioButton(self, -1, 'On', (10, 30)) 
    690691        # best size for MAC and PC 
     
    696697                                      style=wx.BU_EXACTFIT, 
    697698                                      size=size_q) 
    698         self.disp_help_bt.Bind(wx.EVT_BUTTON, 
    699                         self.on_pd_help_clicked, id=self.disp_help_bt.GetId()) 
     699        self.disp_help_bt.Bind(wx.EVT_BUTTON, self.on_pd_help_clicked, 
     700                              id=self.disp_help_bt.GetId()) 
    700701        self.disp_help_bt.SetToolTipString("Helps for Polydispersion.") 
    701702 
    702703        self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param, 
    703                      id=self.disable_disp.GetId()) 
     704                  id=self.disable_disp.GetId()) 
    704705        self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param, 
    705                    id=self.enable_disp.GetId()) 
     706                  id=self.enable_disp.GetId()) 
    706707        #MAC needs SetValue 
    707708        self.disable_disp.SetValue(True) 
     
    718719        ## fill a sizer for dispersion 
    719720        boxsizer1.Add(sizer_dispersion, 0, 
    720                 wx.TOP | wx.BOTTOM | wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 
    721                 border=5) 
     721                      wx.TOP|wx.BOTTOM|wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 
     722                      border=5) 
    722723        self.sizer4_4 = wx.GridBagSizer(6, 5) 
    723724 
     
    778779                        self._manager.parent._default_save_location 
    779780        dlg = wx.FileDialog(self, "Choose a file", self._default_save_location, 
    780                                         self.window_caption, "*.fitv", wx.SAVE) 
     781                            self.window_caption, "*.fitv", wx.SAVE) 
    781782 
    782783        if dlg.ShowModal() == wx.ID_OK: 
     
    784785            self._default_save_location = os.path.dirname(path) 
    785786            self._manager.parent._default_save_location = \ 
    786                                  self._default_save_location 
     787                                self._default_save_location 
    787788        else: 
    788789            return None 
     
    843844        # inform msg to wx 
    844845        wx.PostEvent(self._manager.parent, 
    845                     StatusEvent(status=msg, info=infor)) 
     846                     StatusEvent(status=msg, info=infor)) 
    846847 
    847848    def _get_time_stamp(self): 
     
    912913        try: 
    913914            if path == None: 
     915                status = " Selected Distribution was not loaded: %s" % path 
    914916                wx.PostEvent(self._manager.parent, 
    915                             StatusEvent(status=\ 
    916                             " Selected Distribution was not loaded: %s" % path)) 
     917                             StatusEvent(status=status)) 
    917918                return None, None 
    918919            input_f = open(path, 'r') 
     
    931932                except: 
    932933                    # Skip non-data lines 
    933                     logging.error(sys.exc_value) 
     934                    logging.error(sys.exc_info()[1]) 
    934935            return numpy.array(angles), numpy.array(weights) 
    935936        except: 
     
    10951096        ## save checkbutton state and txtcrtl values 
    10961097        self._copy_parameters_state(self.orientation_params, 
    1097                                      self.state.orientation_params) 
     1098                                    self.state.orientation_params) 
    10981099        self._copy_parameters_state(self.orientation_params_disp, 
    1099                                      self.state.orientation_params_disp) 
     1100                                    self.state.orientation_params_disp) 
    11001101        self._copy_parameters_state(self.parameters, self.state.parameters) 
    11011102        self._copy_parameters_state(self.fittable_param, 
    1102                                              self.state.fittable_param) 
     1103                                    self.state.fittable_param) 
    11031104        self._copy_parameters_state(self.fixed_param, self.state.fixed_param) 
    11041105 
     
    11361137            category_pos = 0 
    11371138            for ind_cat in range(self.categorybox.GetCount()): 
    1138                 if self.categorycombobox.GetString(ind_form) == \ 
     1139                if self.categorycombobox.GetString(ind_cat) == \ 
    11391140                                        state.categorycombobox: 
    11401141                    category_pos = int(ind_cat) 
     
    13651366            else: 
    13661367                self.model_view.SetLabel("1D Mode") 
    1367         # else: 
    1368  
    1369         if self._manager != None and self.engine_type != None: 
    1370             self._manager._on_change_engine(engine=self.engine_type) 
     1368         
    13711369        ## set the select all check box to the a given state 
    13721370        self.cb1.SetValue(state.cb1) 
     
    14801478                                 [state.values, state.weights] 
    14811479            except: 
    1482                 logging.error(sys.exc_value) 
     1480                logging.error(sys.exc_info()[1]) 
    14831481            selection = self._find_polyfunc_selection(disp_model) 
    14841482            for list in self.fittable_param: 
     
    14971495                            list[6].Disable() 
    14981496                        except: 
    1499                             logging.error(sys.exc_value) 
     1497                            logging.error(sys.exc_info()[1]) 
    15001498            # For array, disable all fixed params 
    15011499            if selection == 1: 
     
    15061504                            item[2].Disable() 
    15071505                        except: 
    1508                             logging.error(sys.exc_value) 
     1506                            logging.error(sys.exc_info()[1]) 
    15091507 
    15101508        # Make sure the check box updated when all checked 
     
    15201518                        self._manager.parent.get_save_location() 
    15211519        dlg = wx.FileDialog(self, "Choose a weight file", 
    1522                                 self._default_save_location, "", 
    1523                                 "*.*", wx.OPEN) 
     1520                            self._default_save_location, "", 
     1521                            "*.*", wx.OPEN) 
    15241522        path = None 
    15251523        if dlg.ShowModal() == wx.ID_OK: 
     
    15871585            try: 
    15881586                is_modified = self._check_value_enter(self.fittable_param, 
    1589                                                      is_modified) 
     1587                                                      is_modified) 
    15901588                is_modified = self._check_value_enter(self.fixed_param, 
    15911589                                                      is_modified) 
     
    15931591                                                      is_modified) 
    15941592            except: 
    1595                 logging.error(sys.exc_value) 
     1593                logging.error(sys.exc_info()[1]) 
    15961594 
    15971595            # Here we should check whether the boundaries have been modified. 
     
    16591657            self._check_value_enter(self.parameters, is_modified) 
    16601658 
    1661             # If qmin and qmax have been modified, update qmin and qmax and  
     1659            # If qmin and qmax have been modified, update qmin and qmax and 
    16621660            # Here we should check whether the boundaries have been modified. 
    1663             # If qmin and qmax have been modified, update qmin and qmax and  
     1661            # If qmin and qmax have been modified, update qmin and qmax and 
    16641662            # set the is_modified flag to True 
    16651663            self.fitrange = self._validate_qrange(self.qmin, self.qmax) 
     
    16811679                        flag = self.update_pinhole_smear() 
    16821680                    else: 
     1681                        enable_smearer = not self.disable_smearer.GetValue() 
    16831682                        self._manager.set_smearer(smearer=temp_smearer, 
    16841683                                                  uid=self.uid, 
     
    16861685                                                  qmin=float(self.qmin_x), 
    16871686                                                  qmax=float(self.qmax_x), 
    1688                             enable_smearer=not self.disable_smearer.GetValue(), 
    1689                                                       draw=False) 
     1687                                                  enable_smearer=enable_smearer, 
     1688                                                  draw=False) 
    16901689                elif not self._is_2D(): 
    16911690                    self._manager.set_smearer(smearer=temp_smearer, 
     
    17351734            self.save_current_state() 
    17361735        except: 
    1737             logging.error(sys.exc_value) 
     1736            logging.error(sys.exc_info()[1]) 
    17381737 
    17391738        return flag 
     
    19901989                    #                 StatusEvent(status=msg, info="error")) 
    19911990        except: 
    1992             msg = "%s\n" % (sys.exc_value) 
     1991            msg = "%s\n" % (sys.exc_info()[1]) 
    19931992            wx.PostEvent(self._manager.parent, 
    19941993                         StatusEvent(status=msg, info="error")) 
     
    19961995 
    19971996    def _on_modify_cat(self, event=None): 
     1997        """ 
     1998        Called when category manager is opened 
     1999        """ 
    19982000        self._manager.parent.on_category_panel(event) 
    19992001 
     
    20592061                else: 
    20602062                    tcrtl.SetBackgroundColour("pink") 
    2061                     msg = "Model Error: wrong value entered: %s" % sys.exc_value 
     2063                    msg = "Model Error: wrong value entered: %s" % \ 
     2064                                    sys.exc_info()[1] 
    20622065                    wx.PostEvent(self.parent, StatusEvent(status=msg)) 
    20632066                    return 
    20642067            except: 
    20652068                tcrtl.SetBackgroundColour("pink") 
    2066                 msg = "Model Error: wrong value entered: %s" % sys.exc_value 
     2069                msg = "Model Error: wrong value entered: %s" % sys.exc_info()[1] 
    20672070                wx.PostEvent(self.parent, StatusEvent(status=msg)) 
    20682071                return 
     
    21162119                else: 
    21172120                    tcrtl.SetBackgroundColour("pink") 
    2118                     msg = "Model Error: wrong value entered: %s" % sys.exc_value 
     2121                    msg = "Model Error: wrong value entered: %s" % \ 
     2122                                        sys.exc_info()[1] 
    21192123                    wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
    21202124                    return 
    21212125            except: 
    21222126                tcrtl.SetBackgroundColour("pink") 
    2123                 msg = "Model Error: wrong value entered: %s" % sys.exc_value 
     2127                msg = "Model Error: wrong value entered: %s" % sys.exc_info()[1] 
    21242128                wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
    21252129                return 
     
    25512555                    self.model.set_dispersion(p, disp_model) 
    25522556                except: 
    2553                     logging.error(sys.exc_value) 
     2557                    logging.error(sys.exc_info()[1]) 
    25542558 
    25552559        ## save state into 
     
    27642768            del self.state.model._persistency_dict[name.split('.')[0]] 
    27652769        except: 
    2766             logging.error(sys.exc_value) 
     2770            logging.error(sys.exc_info()[1]) 
    27672771 
    27682772    def _lay_out(self): 
     
    29102914            except: 
    29112915                # Not for control panels 
    2912                 logging.error(sys.exc_value) 
     2916                logging.error(sys.exc_info()[1]) 
    29132917        # Make sure the resduals plot goes to the last 
    29142918        if res_item != None: 
     
    32263230                    disfunc = str(item[7].GetValue()) 
    32273231            except: 
    3228                 logging.error(sys.exc_value) 
     3232                logging.error(sys.exc_info()[1]) 
    32293233 
    32303234            # 2D 
     
    32613265                        disfunc += ' ' + str(weight) 
    32623266            except: 
    3263                 logging.error(sys.exc_value) 
     3267                logging.error(sys.exc_info()[1]) 
    32643268            content += name + ',' + str(check) + ',' + value + disfunc + ':' 
    32653269 
     
    34623466                            is_array = True 
    34633467                except: 
    3464                     logging.error(sys.exc_value) 
     3468                    logging.error(sys.exc_info()[1]) 
    34653469                if not is_array: 
    34663470                    self._disp_obj_dict[name] = disp_model 
     
    34773481 
    34783482            except: 
    3479                 logging.error(sys.exc_value) 
    3480                 print "Error in BasePage._paste_poly_help: %s" % sys.exc_value 
     3483                logging.error(sys.exc_info()[1]) 
     3484                print "Error in BasePage._paste_poly_help: %s" % \ 
     3485                                        sys.exc_info()[1] 
    34813486 
    34823487    def _set_disp_array_cb(self, item): 
     
    35023507        return 
    35033508 
    3504  
    3505  
    3506  
    35073509    def _read_category_info(self): 
    35083510        """ 
    35093511        Reads the categories in from file 
    35103512        """ 
    3511  
    35123513        # # ILL mod starts here - July 2012 kieranrcampbell@gmail.com 
    35133514        self.master_category_dict = defaultdict(list) 
     
    35233524            self._regenerate_model_dict() 
    35243525            cat_file.close() 
    3525  
    35263526        except IOError: 
    35273527            raise 
     
    35363536        along with the enabled mapping 
    35373537        """ 
    3538  
    35393538        self.by_model_dict = defaultdict(list) 
    35403539        for category in self.master_category_dict: 
     
    35643563            self.categorybox.SetSelection(\ 
    35653564                self.categorybox.GetSelection()) 
    3566  
    35673565        #self._on_change_cat(None) 
    3568  
    35693566 
    35703567    def _on_change_cat(self, event): 
     
    35883585                if(enabled): 
    35893586                    self.model_box.Append(model) 
    3590  
    3591  
    3592  
    35933587 
    35943588    def _fill_model_sizer(self, sizer): 
     
    36543648 
    36553649        sizer_radiobutton = wx.GridSizer(2, 2, 5, 5) 
    3656  
    3657  
    36583650        #sizer_radiobutton.Add(self.shape_rbutton) 
    36593651        #sizer_radiobutton.Add(self.shape_indep_rbutton) 
Note: See TracChangeset for help on using the changeset viewer.