Changeset 489f53a in sasview for src/sas/sasgui/perspectives/fitting


Ignore:
Timestamp:
Aug 7, 2017 6:39:28 AM (7 years ago)
Author:
lewis
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.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
4627657
Parents:
b1c2011
Message:

Show warning message before deleting plug-in model. Refs #754

File:
1 edited

Legend:

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

    ra534432 r489f53a  
    257257        toks = os.path.splitext(label) 
    258258        path = os.path.join(models.find_plugins_dir(), toks[0]) 
     259        message = "Are you sure you want to delete the file {}?".format(path) 
     260        dlg = wx.MessageDialog(self.frame, message, '', wx.YES_NO | wx.ICON_QUESTION) 
     261        if not dlg.ShowModal() == wx.ID_YES: 
     262            return 
    259263        try: 
    260264            for ext in ['.py', '.pyc']: 
    261265                p_path = path + ext 
     266                if ext == '.pyc' and not os.path.isfile(path + ext): 
     267                    # If model is invalid, .pyc file may not exist as model has 
     268                    # never been compiled. Don't try and delete it 
     269                    continue 
    262270                os.remove(p_path) 
    263271            self.update_custom_combo() 
     
    361369                                   'Add a new model function') 
    362370        wx.EVT_MENU(owner, wx_id, self.make_new_model) 
    363          
     371 
    364372        wx_id = wx.NewId() 
    365373        self.edit_model_menu.Append(wx_id, 'Sum|Multi(p1, p2)', 
     
    383391          '(Re)Load all models present in user plugin_models folder') 
    384392        wx.EVT_MENU(owner, wx_id, self.load_plugin_models) 
    385                  
     393 
    386394    def set_edit_menu_helper(self, owner=None, menu=None): 
    387395        """ 
     
    17341742            @param unsmeared_error: data error, rescaled to unsmeared model 
    17351743        """ 
    1736              
    1737         number_finite = np.count_nonzero(np.isfinite(y))  
     1744 
     1745        number_finite = np.count_nonzero(np.isfinite(y)) 
    17381746        np.nan_to_num(y) 
    17391747        new_plot = self.create_theory_1D(x, y, page_id, model, data, state, 
     
    17941802            msg = "Computing Error: Model did not return any finite value." 
    17951803            wx.PostEvent(self.parent, StatusEvent(status = msg, info="error")) 
    1796         else:                  
     1804        else: 
    17971805            msg = "Computation  completed!" 
    17981806            if number_finite != y.size: 
     
    18241832        that can be plot. 
    18251833        """ 
    1826         number_finite = np.count_nonzero(np.isfinite(image))  
     1834        number_finite = np.count_nonzero(np.isfinite(image)) 
    18271835        np.nan_to_num(image) 
    18281836        new_plot = Data2D(image=image, err_image=data.err_data) 
     
    19271935                ## and may be the cause of other noted instabilities 
    19281936                ## 
    1929                 ##    -PDB August 12, 2014  
     1937                ##    -PDB August 12, 2014 
    19301938                while self.calc_2D.isrunning(): 
    19311939                    time.sleep(0.1) 
     
    19691977            if (self.calc_1D is not None) and self.calc_1D.isrunning(): 
    19701978                self.calc_1D.stop() 
    1971                 ## stop just raises the flag -- the thread is supposed to  
     1979                ## stop just raises the flag -- the thread is supposed to 
    19721980                ## then kill itself but cannot.  Paul Kienzle came up with 
    19731981                ## this fix to prevent threads from stepping on each other 
     
    19811989                ## a request to stop the computation. 
    19821990                ## It seems thus that the whole thread approach used here 
    1983                 ## May need rethinking   
     1991                ## May need rethinking 
    19841992                ## 
    19851993                ##    -PDB August 12, 2014 
     
    21462154            residuals.dxw = None 
    21472155            residuals.ytransform = 'y' 
    2148             # For latter scale changes  
     2156            # For latter scale changes 
    21492157            residuals.xaxis('\\rm{Q} ', 'A^{-1}') 
    21502158            residuals.yaxis('\\rm{Residuals} ', 'normalized') 
Note: See TracChangeset for help on using the changeset viewer.