Changeset 7cd87c2 in sasview


Ignore:
Timestamp:
Mar 4, 2015 1:18:11 PM (9 years ago)
Author:
Doucet, Mathieu <doucetm@…>
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:
af6b53c
Parents:
b6627d9
Message:

pylint fixes and remove except followed by pass

File:
1 edited

Legend:

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

    rc1694f8 r7cd87c2  
    1111import string 
    1212import json 
     13import logging 
    1314from collections import defaultdict 
    1415from wx.lib.scrolledpanel import ScrolledPanel 
     
    5657    ## Title to appear on top of the window 
    5758    window_caption = "Fit Page " 
    58      
     59 
    5960    def __init__(self, parent, color='blue', **kwargs): 
    6061        """ 
     
    6566        #Set window's font size 
    6667        self.SetWindowVariant(variant=FONT_VARIANT) 
    67        
     68 
    6869        self.SetBackgroundColour(color) 
    6970        ## parent of the page 
     
    127128        self.Npts_fit = None 
    128129        self.Npts_total = None 
    129         self.theory_qmin = None  
     130        self.theory_qmin = None 
    130131        self.theory_qmax = None 
    131132        self.theory_qmin_x = None 
     
    136137        self.sld_axes = None 
    137138        self.multi_factor = None 
    138         
     139 
    139140        self.disp_cb_dict = {} 
    140     
     141 
    141142        #self.state = PageState(parent=parent) 
    142143        ## dictionary containing list of models 
    143144        self.model_list_box = {} 
    144         
     145 
    145146        ## Data member to store the dispersion object created 
    146147        self._disp_obj_dict = {} 
     
    170171        self.disp_list = [] 
    171172        self.disp_name = "" 
    172          
     173 
    173174        ## list of orientation parameters 
    174175        self.orientation_params = [] 
     
    199200        ## Create context menu for page 
    200201        self.popUpMenu = wx.Menu() 
    201      
     202 
    202203        id = wx.NewId() 
    203204        self._keep = wx.MenuItem(self.popUpMenu, id, "Add bookmark", 
     
    209210        wx.EVT_MENU(self, id, self.on_bookmark) 
    210211        self.popUpMenu.AppendSeparator() 
    211      
     212 
    212213        ## Default locations 
    213214        self._default_save_location = os.getcwd() 
     
    215216        #self.onSave(event=None) 
    216217        self.Bind(wx.EVT_CONTEXT_MENU, self.onContextMenu) 
    217          
     218 
    218219        # bind key event 
    219220        self.Bind(wx.EVT_LEFT_DOWN, self.on_left_down) 
    220          
     221 
    221222        ## create the basic structure of the panel with empty sizer 
    222223        self.define_page_structure() 
    223224        ## drawing Initial dispersion parameters sizer 
    224225        self.set_dispers_sizer() 
    225          
     226 
    226227        ## layout 
    227228        self.set_layout() 
    228      
     229 
    229230    def set_index_model(self, index): 
    230231        """ 
     
    232233        """ 
    233234        self.index_model = index 
    234          
     235 
    235236    def create_default_data(self): 
    236237        """ 
     
    249250                else: 
    250251                    self._create_default_1d_data() 
    251                          
     252 
    252253            if self.model != None: 
    253254                if not self.data.is_data: 
     
    259260            self.state.pinhole_smearer = self.pinhole_smearer.GetValue() 
    260261            self.state.slit_smearer = self.slit_smearer.GetValue() 
    261          
     262 
    262263    def _create_default_1d_data(self): 
    263264        """ 
     
    265266        Only when the page is on theory mode. 
    266267        :warning: This data is never plotted. 
    267          
     268 
    268269        """ 
    269270        x = numpy.linspace(start=self.qmin_x, stop=self.qmax_x, 
     
    275276        self.data.id = str(self.uid) + " data" 
    276277        self.data.group_id = str(self.uid) + " Model1D" 
    277           
     278 
    278279    def _create_log_1d_data(self): 
    279280        """ 
     
    281282        Only when the page is on theory mode. 
    282283        :warning: This data is never plotted. 
    283          
     284 
    284285        """ 
    285286        if self.qmin_x >= 1.e-10: 
    286287            qmin = numpy.log10(self.qmin_x) 
    287288        else: 
    288             qmin = -10.     
    289              
     289            qmin = -10. 
     290 
    290291        if self.qmax_x <= 1.e10: 
    291292            qmax = numpy.log10(self.qmax_x) 
    292293        else: 
    293             qmax = 10.  
    294                 
     294            qmax = 10. 
     295 
    295296        x = numpy.logspace(start=qmin, stop=qmax, 
    296297                           num=self.npts_x, endpoint=True, base=10.0) 
     
    301302        self.data.id = str(self.uid) + " data" 
    302303        self.data.group_id = str(self.uid) + " Model1D" 
    303        
     304 
    304305    def _create_default_2d_data(self): 
    305306        """ 
     
    359360        #xstep = x_size / len(x_bins - 1) 
    360361        #ystep = y_size / len(y_bins - 1) 
    361    
     362 
    362363        self.data.source = Source() 
    363364        self.data.data = numpy.ones(len(mask)) 
     
    382383            wx.PostEvent(self._manager.parent, PanelOnFocusEvent(panel=self)) 
    383384            self.on_tap_focus() 
    384                 
     385 
    385386    def on_tap_focus(self): 
    386387        """ 
     
    398399                    self._manager.menu1.FindItemById(self._manager.id_batchfit) 
    399400            batch_menu.Enable(self.batch_on and flag) 
    400      
     401 
    401402    class ModelTextCtrl(wx.TextCtrl): 
    402403        """ 
     
    404405        Binds the appropriate events for user interactions. 
    405406        Default callback methods can be overwritten on initialization 
    406          
     407 
    407408        :param kill_focus_callback: callback method for EVT_KILL_FOCUS event 
    408409        :param set_focus_callback:  callback method for EVT_SET_FOCUS event 
    409410        :param mouse_up_callback:   callback method for EVT_LEFT_UP event 
    410411        :param text_enter_callback: callback method for EVT_TEXT_ENTER event 
    411          
     412 
    412413        """ 
    413414        ## Set to True when the mouse is clicked while whole string is selected 
     
    415416        ## Call back for EVT_SET_FOCUS events 
    416417        _on_set_focus_callback = None 
    417          
    418         def __init__(self, parent, id=-1, 
     418 
     419        def __init__(self, parent, id= -1, 
    419420                     value=wx.EmptyString, 
    420421                     pos=wx.DefaultPosition, 
     
    427428                     mouse_up_callback=None, 
    428429                     text_enter_callback=None): 
    429               
     430 
    430431            wx.TextCtrl.__init__(self, parent, id, value, pos, 
    431432                                  size, style, validator, name) 
    432              
     433 
    433434            # Bind appropriate events 
    434435            self._on_set_focus_callback = parent.onSetFocus \ 
     
    442443                self.Bind(wx.EVT_LEFT_UP, self._highlight_text \ 
    443444                          if mouse_up_callback is None else mouse_up_callback) 
    444              
     445 
    445446        def _on_set_focus(self, event): 
    446447            """ 
    447448            Catch when the text control is set in focus to highlight the whole 
    448449            text if necessary 
    449              
     450 
    450451            :param event: mouse event 
    451              
     452 
    452453            """ 
    453454            event.Skip() 
    454455            self.full_selection = True 
    455456            return self._on_set_focus_callback(event) 
    456          
     457 
    457458        def _highlight_text(self, event): 
    458459            """ 
    459460            Highlight text of a TextCtrl only of no text has be selected 
    460              
     461 
    461462            :param event: mouse event 
    462              
     463 
    463464            """ 
    464465            # Make sure the mouse event is available to other listeners 
     
    474475                    if start == end: 
    475476                        control.SetSelection(-1, -1) 
    476                          
     477 
    477478        def _silent_kill_focus(self, event): 
    478479            """ 
    479480            Save the state of the page 
    480481            """ 
    481              
     482 
    482483            event.Skip() 
    483484            #pass 
    484      
     485 
    485486    def set_page_info(self, page_info): 
    486487        """ 
     
    511512        ## Data member to store the dispersion object created 
    512513        self.populate_box(model_dict=self.model_list_box) 
    513          
     514 
    514515    def onContextMenu(self, event): 
    515516        """ 
     
    518519        # Skipping the save state functionality for release 0.9.0 
    519520        #return 
    520      
     521 
    521522        pos = event.GetPosition() 
    522523        pos = self.ScreenToClient(pos) 
    523         
     524 
    524525        self.PopupMenu(self.popUpMenu, pos) 
    525        
     526 
    526527    def onUndo(self, event): 
    527528        """ 
     
    530531        event = PreviousStateEvent(page=self) 
    531532        wx.PostEvent(self.parent, event) 
    532          
     533 
    533534    def onRedo(self, event): 
    534535        """ 
     
    537538        event = NextStateEvent(page=self) 
    538539        wx.PostEvent(self.parent, event) 
    539      
     540 
    540541    def define_page_structure(self): 
    541542        """ 
     
    550551        self.sizer5 = wx.BoxSizer(wx.VERTICAL) 
    551552        self.sizer6 = wx.BoxSizer(wx.VERTICAL) 
    552          
     553 
    553554        self.sizer0.SetMinSize((PANEL_WIDTH, -1)) 
    554555        self.sizer1.SetMinSize((PANEL_WIDTH, -1)) 
     
    558559        self.sizer5.SetMinSize((PANEL_WIDTH, -1)) 
    559560        self.sizer6.SetMinSize((PANEL_WIDTH, -1)) 
    560          
     561 
    561562        self.vbox.Add(self.sizer0) 
    562563        self.vbox.Add(self.sizer1) 
     
    566567        self.vbox.Add(self.sizer5) 
    567568        self.vbox.Add(self.sizer6) 
    568          
     569 
    569570    def set_layout(self): 
    570571        """ 
     
    575576        self.SetSizer(self.vbox) 
    576577        self.Centre() 
    577   
     578 
    578579    def set_owner(self, owner): 
    579580        """ 
    580581        set owner of fitpage 
    581          
     582 
    582583        :param owner: the class responsible of plotting 
    583          
     584 
    584585        """ 
    585586        self.event_owner = owner 
    586587        self.state.event_owner = owner 
    587          
     588 
    588589    def get_state(self): 
    589590        """ 
    590591        """ 
    591592        return self.state 
    592      
     593 
    593594    def get_data(self): 
    594595        """ 
     
    596597        """ 
    597598        return self.data 
    598      
     599 
    599600    def get_data_list(self): 
    600601        """ 
     
    602603        """ 
    603604        return self.data_list 
    604      
     605 
    605606    def set_manager(self, manager): 
    606607        """ 
    607608        set panel manager 
    608          
     609 
    609610        :param manager: instance of plugin fitting 
    610          
     611 
    611612        """ 
    612613        self._manager = manager 
    613614        self.state.manager = manager 
    614          
     615 
    615616    def populate_box(self, model_dict): 
    616617        """ 
    617618        Store list of model 
    618          
     619 
    619620        :param model_dict: dictionary containing list of models 
    620          
     621 
    621622        """ 
    622623        self.model_list_box = model_dict 
    623624        self.state.model_list_box = self.model_list_box 
    624625        self.initialize_combox() 
    625          
     626 
    626627    def set_model_dictionary(self, model_dict): 
    627628        """ 
     
    635636        """ 
    636637        put default value in the combobox 
    637         """   
     638        """ 
    638639        ## fill combox box 
    639640        if self.model_list_box is None: 
     
    666667            self.structurebox.Disable() 
    667668            self.text2.Disable() 
    668               
     669 
    669670            if self.model.__class__ in self.model_list_box["P(Q)*S(Q)"]: 
    670671                self.structurebox.Show() 
     
    673674                self.text2.Enable() 
    674675 
    675                  
     676 
    676677    def set_dispers_sizer(self): 
    677678        """ 
     
    698699                        self.on_pd_help_clicked, id=self.disp_help_bt.GetId()) 
    699700        self.disp_help_bt.SetToolTipString("Helps for Polydispersion.") 
    700          
     701 
    701702        self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param, 
    702703                     id=self.disable_disp.GetId()) 
     
    714715        sizer_dispersion.Add((25, 20)) 
    715716        sizer_dispersion.Add(self.disp_help_bt) 
    716          
     717 
    717718        ## fill a sizer for dispersion 
    718719        boxsizer1.Add(sizer_dispersion, 0, 
     
    727728        self.sizer4.Layout() 
    728729        self.Layout() 
    729       
     730 
    730731        self.Refresh() 
    731732        ## saving the state of enable dispersity button 
     
    733734        self.state.disable_disp = self.disable_disp.GetValue() 
    734735        self.SetupScrolling() 
    735      
     736 
    736737    def onResetModel(self, event): 
    737738        """ 
     
    751752            previous_state = self.saved_states[name] 
    752753            ## reset state of checkbox,textcrtl  and  regular parameters value 
    753              
     754 
    754755            self.reset_page(previous_state) 
    755756        self.state.m_name = self.m_name 
    756757        self.Show(True) 
    757                 
     758 
    758759    def on_preview(self, event): 
    759760        """ 
     
    764765        # get the report dialog 
    765766        self.state.report(images, canvases) 
    766          
     767 
    767768    def on_save(self, event): 
    768769        """ 
     
    782783            path = dlg.GetPath() 
    783784            self._default_save_location = os.path.dirname(path) 
    784             self._manager.parent._default_save_location =\ 
     785            self._manager.parent._default_save_location = \ 
    785786                                 self._default_save_location 
    786787        else: 
     
    793794        self._manager.save_fit_state(filepath=fName, fitstate=new_state) 
    794795        return new_state 
    795      
     796 
    796797    def on_copy(self, event): 
    797798        """ 
     
    810811            wx.CallAfter(self.get_copy) 
    811812 
    812          
     813 
    813814    def on_paste(self, event): 
    814815        """ 
     
    822823        # messages depending on the flag 
    823824        #self._copy_info(True) 
    824          
     825 
    825826    def _copy_info(self, flag): 
    826827        """ 
    827828        Send event dpemding on flag 
    828          
     829 
    829830        : Param flag: flag that distinguish event 
    830831        """ 
     
    843844        wx.PostEvent(self._manager.parent, 
    844845                    StatusEvent(status=msg, info=infor)) 
    845          
     846 
    846847    def _get_time_stamp(self): 
    847848        """ 
     
    853854        current_date = str(month) + "/" + str(day) + "/" + str(year) 
    854855        return current_time, current_date 
    855        
     856 
    856857    def on_bookmark(self, event): 
    857858        """ 
     
    872873        name += "bookmarked at %s on %s" % (current_time, current_date) 
    873874        self.saved_states[name] = new_state 
    874          
     875 
    875876        ## Add item in the context menu 
    876877        msg = "Model saved at %s on %s" % (current_time, current_date) 
     
    878879        msg += " Saved! right click on this page to retrieve this model" 
    879880        wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
    880          
     881 
    881882        id = wx.NewId() 
    882883        self.popUpMenu.Append(id, name, str(msg)) 
     
    886887                                         hint=str(msg), 
    887888                                         handler=self._back_to_bookmark)) 
    888      
     889 
    889890    def _back_to_bookmark(self, event): 
    890891        """ 
     
    894895        self.onResetModel(event) 
    895896        self._draw_model() 
    896                  
     897 
    897898    def onSetFocus(self, evt): 
    898899        """ 
     
    901902        """ 
    902903        return 
    903      
     904 
    904905    def read_file(self, path): 
    905906        """ 
    906907        Read two columns file 
    907          
     908 
    908909        :param path: the path to the file to read 
    909          
     910 
    910911        """ 
    911912        try: 
    912913            if path == None: 
    913914                wx.PostEvent(self._manager.parent, 
    914                             StatusEvent(status= \ 
     915                            StatusEvent(status=\ 
    915916                            " Selected Distribution was not loaded: %s" % path)) 
    916917                return None, None 
     
    930931                except: 
    931932                    # Skip non-data lines 
    932                     pass 
     933                    logging.error(sys.exc_value) 
    933934            return numpy.array(angles), numpy.array(weights) 
    934935        except: 
     
    940941        """ 
    941942        return self.state.clone() 
    942      
     943 
    943944    def save_current_state(self): 
    944945        """ 
     
    951952            self.state.disp_list = copy.deepcopy(self.disp_list) 
    952953            self.state.model = self.model.clone() 
    953              
     954 
    954955            #model combobox: complex code because of mac's silent error 
    955956            if self.structurebox != None: 
     
    970971                self.state.categorycombobox = self.categorybox.\ 
    971972                GetString(cb_select) 
    972          
     973 
    973974        self.state.enable2D = copy.deepcopy(self.enable2D) 
    974975        self.state.values = copy.deepcopy(self.values) 
     
    987988            self.state.enable_disp = self.enable_disp.GetValue() 
    988989            self.state.disable_disp = self.disable_disp.GetValue() 
    989              
     990 
    990991        self.state.smearer = copy.deepcopy(self.current_smearer) 
    991992        if hasattr(self, "enable_smearer"): 
     
    10021003        self.state.dxw = copy.deepcopy(self.dxw) 
    10031004        self.state.slit_smearer = copy.deepcopy(self.slit_smearer.GetValue()) 
    1004                    
     1005 
    10051006        if len(self._disp_obj_dict) > 0: 
    10061007            for k, v in self._disp_obj_dict.iteritems(): 
     
    10111012        ## save plotting range 
    10121013        self._save_plotting_range() 
    1013          
     1014 
    10141015        self.state.orientation_params = [] 
    10151016        self.state.orientation_params_disp = [] 
     
    10261027        self._copy_parameters_state(self.orientation_params_disp, 
    10271028                                     self.state.orientation_params_disp) 
    1028          
     1029 
    10291030        self._copy_parameters_state(self.parameters, self.state.parameters) 
    10301031        self._copy_parameters_state(self.fittable_param, 
     
    10331034        #save chisqr 
    10341035        self.state.tcChi = self.tcChi.GetValue() 
    1035          
     1036 
    10361037    def save_current_state_fit(self): 
    10371038        """ 
     
    10451046        if hasattr(self, "engine_type"): 
    10461047            self.state.engine_type = copy.deepcopy(self.engine_type) 
    1047              
     1048 
    10481049        self.state.enable2D = copy.deepcopy(self.enable2D) 
    10491050        self.state.values = copy.deepcopy(self.values) 
     
    10511052        ## save data 
    10521053        self.state.data = copy.deepcopy(self.data) 
    1053          
     1054 
    10541055        if hasattr(self, "enable_disp"): 
    10551056            self.state.enable_disp = self.enable_disp.GetValue() 
    10561057            self.state.disable_disp = self.disable_disp.GetValue() 
    1057              
     1058 
    10581059        self.state.smearer = copy.deepcopy(self.current_smearer) 
    10591060        if hasattr(self, "enable_smearer"): 
     
    10621063            self.state.disable_smearer = \ 
    10631064                                copy.deepcopy(self.disable_smearer.GetValue()) 
    1064              
     1065 
    10651066        self.state.pinhole_smearer = \ 
    10661067                                copy.deepcopy(self.pinhole_smearer.GetValue()) 
     
    10851086                for k, v in self._disp_obj_dict.iteritems(): 
    10861087                    self.state._disp_obj_dict[k] = v 
    1087                          
     1088 
    10881089            self.state.values = copy.deepcopy(self.values) 
    10891090            self.state.weights = copy.deepcopy(self.weights) 
    1090             
     1091 
    10911092        ## save plotting range 
    10921093        self._save_plotting_range() 
    1093          
     1094 
    10941095        ## save checkbutton state and txtcrtl values 
    10951096        self._copy_parameters_state(self.orientation_params, 
     
    11011102                                             self.state.fittable_param) 
    11021103        self._copy_parameters_state(self.fixed_param, self.state.fixed_param) 
    1103      
     1104 
    11041105    def check_invalid_panel(self): 
    11051106        """ 
     
    11121113            wx.MessageBox(msg, 'Info') 
    11131114            return  True 
    1114          
     1115 
    11151116    def set_model_state(self, state): 
    11161117        """ 
     
    11191120        self.disp_cb_dict = state.disp_cb_dict 
    11201121        self.disp_list = state.disp_list 
    1121        
     1122 
    11221123        ## set the state of the radio box 
    11231124        #self.shape_rbutton.SetValue(state.shape_rbutton) 
     
    11251126        #self.struct_rbutton.SetValue(state.struct_rbutton) 
    11261127        #self.plugin_rbutton.SetValue(state.plugin_rbutton) 
    1127          
     1128 
    11281129        ## fill model combobox 
    11291130        self._show_combox_helper() 
     
    11391140                    category_pos = int(ind_cat) 
    11401141                    break 
    1141              
     1142 
    11421143        self.categorybox.Select(category_pos) 
    11431144        try: 
     
    11511152                    formfactor_pos = int(ind_form) 
    11521153                    break 
    1153              
     1154 
    11541155        self.formfactorbox.Select(formfactor_pos) 
    1155          
     1156 
    11561157        try: 
    11571158            # to support older version 
     
    11641165                    structfactor_pos = int(ind_struct) 
    11651166                    break 
    1166                  
     1167 
    11671168        self.structurebox.SetSelection(structfactor_pos) 
    1168          
     1169 
    11691170        if state.multi_factor != None: 
    11701171            self.multifactorbox.SetSelection(state.multi_factor) 
    1171              
     1172 
    11721173        ## reset state of checkbox,textcrtl  and  regular parameters value 
    11731174        self._reset_parameters_state(self.orientation_params_disp, 
     
    11811182        self.enable_disp.SetValue(state.enable_disp) 
    11821183        self.disable_disp.SetValue(state.disable_disp) 
    1183          
     1184 
    11841185        if hasattr(self, "disp_box") and self.disp_box != None: 
    11851186            self.disp_box.SetSelection(state.disp_box) 
     
    11891190 
    11901191            self._set_dipers_Param(event=None) 
    1191         
     1192 
    11921193            if name == "ArrayDispersion": 
    1193                  
     1194 
    11941195                for item in self.disp_cb_dict.keys(): 
    1195                      
     1196 
    11961197                    if hasattr(self.disp_cb_dict[item], "SetValue"): 
    11971198                        self.disp_cb_dict[item].SetValue(\ 
     
    12091210                            else: 
    12101211                                self._reset_dispersity() 
    1211                          
     1212 
    12121213                        self._disp_obj_dict[item] = disp_model 
    12131214                        # Set the new model as the dispersion object 
    12141215                        #for the selected parameter 
    12151216                        self.model.set_dispersion(item, disp_model) 
    1216                      
     1217 
    12171218                        self.model._persistency_dict[item] = \ 
    12181219                                                [state.values, state.weights] 
    1219                      
     1220 
    12201221            else: 
    12211222                keys = self.model.getParamList() 
     
    12351236        self.pinhole_smearer.SetValue(state.pinhole_smearer) 
    12361237        self.slit_smearer.SetValue(state.slit_smearer) 
    1237          
     1238 
    12381239        self.dI_noweight.SetValue(state.dI_noweight) 
    12391240        self.dI_didata.SetValue(state.dI_didata) 
    12401241        self.dI_sqrdata.SetValue(state.dI_sqrdata) 
    12411242        self.dI_idata.SetValue(state.dI_idata) 
    1242          
     1243 
    12431244        ## we have two more options for smearing 
    12441245        if self.pinhole_smearer.GetValue(): 
     
    12461247        elif self.slit_smearer.GetValue(): 
    12471248            self.onSlitSmear(event=None) 
    1248         
     1249 
    12491250        ## reset state of checkbox,textcrtl  and dispersity parameters value 
    12501251        self._reset_parameters_state(self.fittable_param, state.fittable_param) 
    12511252        self._reset_parameters_state(self.fixed_param, state.fixed_param) 
    1252          
     1253 
    12531254        ## draw the model with previous parameters value 
    12541255        self._onparamEnter_helper() 
     
    12581259        self._lay_out() 
    12591260        self.Refresh() 
    1260          
     1261 
    12611262    def reset_page_helper(self, state): 
    12621263        """ 
    12631264        Use page_state and change the state of existing page 
    1264          
     1265 
    12651266        :precondition: the page is already drawn or created 
    1266          
     1267 
    12671268        :postcondition: the state of the underlying data change as well as the 
    12681269            state of the graphic interface 
     
    12901291        else: 
    12911292            self.set_data(data) 
    1292              
     1293 
    12931294        self.enable2D = state.enable2D 
    12941295        try: 
     
    13011302        self.disp_cb_dict = state.disp_cb_dict 
    13021303        self.disp_list = state.disp_list 
    1303        
     1304 
    13041305        ## set the state of the radio box 
    13051306        #self.shape_rbutton.SetValue(state.shape_rbutton) 
     
    13071308        #self.struct_rbutton.SetValue(state.struct_rbutton) 
    13081309        #self.plugin_rbutton.SetValue(state.plugin_rbutton) 
    1309          
     1310 
    13101311        ## fill model combobox 
    13111312        self._show_combox_helper() 
     
    13211322                    category_pos = int(ind_cat) 
    13221323                    break 
    1323              
     1324 
    13241325        self.categorybox.Select(category_pos) 
    13251326        self._show_combox(None) 
     
    13341335                    formfactor_pos = int(ind_form) 
    13351336                    break 
    1336              
     1337 
    13371338        self.formfactorbox.Select(formfactor_pos) 
    1338          
     1339 
    13391340        try: 
    13401341            # to support older version 
     
    13471348                    structfactor_pos = int(ind_struct) 
    13481349                    break 
    1349              
     1350 
    13501351        self.structurebox.SetSelection(structfactor_pos) 
    13511352 
     
    13571358        #draw the pnael according to the new model parameter 
    13581359        self._on_select_model(event=None) 
    1359              
     1360 
    13601361        # take care of 2D button 
    13611362        if data == None and self.model_view.IsEnabled(): 
     
    13651366                self.model_view.SetLabel("1D Mode") 
    13661367        # else: 
    1367                  
     1368 
    13681369        if self._manager != None and self.engine_type != None: 
    13691370            self._manager._on_change_engine(engine=self.engine_type) 
    13701371        ## set the select all check box to the a given state 
    13711372        self.cb1.SetValue(state.cb1) 
    1372       
     1373 
    13731374        ## reset state of checkbox,textcrtl  and  regular parameters value 
    13741375        self._reset_parameters_state(self.orientation_params_disp, 
     
    14091410            self.dI_sqrdata.SetValue(False) 
    14101411            self.dI_idata.SetValue(False) 
    1411   
     1412 
    14121413        ## we have two more options for smearing 
    14131414        if self.pinhole_smearer.GetValue(): 
     
    14251426                self.smear_slit_height.SetValue(str(self.dxl)) 
    14261427            if self.dxw != None: 
    1427                 self.smear_slit_width.SetValue(str(self.dxw))   
     1428                self.smear_slit_width.SetValue(str(self.dxw)) 
    14281429            else: 
    1429                 self.smear_slit_width.SetValue('')   
     1430                self.smear_slit_width.SetValue('') 
    14301431            self.onSlitSmear(event=None) 
    1431          
     1432 
    14321433        ## reset state of checkbox,textcrtl  and dispersity parameters value 
    14331434        self._reset_parameters_state(self.fittable_param, state.fittable_param) 
    14341435        self._reset_parameters_state(self.fixed_param, state.fixed_param) 
    1435          
     1436 
    14361437        ## draw the model with previous parameters value 
    14371438        self._onparamEnter_helper() 
     
    14401441        ## reset context menu items 
    14411442        self._reset_context_menu() 
    1442          
     1443 
    14431444        ## set the value of the current state to the state given as parameter 
    14441445        self.state = state.clone() 
    14451446        self.state.m_name = self.m_name 
    1446      
     1447 
    14471448    def _reset_page_disp_helper(self, state): 
    14481449        """ 
     
    14591460        self.values = copy.deepcopy(state.values) 
    14601461        self.weights = copy.deepcopy(state.weights) 
    1461          
     1462 
    14621463        for key, disp in state._disp_obj_dict.iteritems(): 
    14631464            # From saved file, disp_model can not be sent in model obj. 
     
    14791480                                 [state.values, state.weights] 
    14801481            except: 
    1481                 pass 
     1482                logging.error(sys.exc_value) 
    14821483            selection = self._find_polyfunc_selection(disp_model) 
    14831484            for list in self.fittable_param: 
     
    14961497                            list[6].Disable() 
    14971498                        except: 
    1498                             pass 
     1499                            logging.error(sys.exc_value) 
    14991500            # For array, disable all fixed params 
    15001501            if selection == 1: 
     
    15051506                            item[2].Disable() 
    15061507                        except: 
    1507                             pass 
    1508      
     1508                            logging.error(sys.exc_value) 
     1509 
    15091510        # Make sure the check box updated when all checked 
    15101511        if self.cb1.GetValue(): 
    15111512            self.select_all_param(None) 
    1512        
     1513 
    15131514    def _selectDlg(self): 
    15141515        """ 
    1515         open a dialog file to selected the customized dispersity  
     1516        open a dialog file to selected the customized dispersity 
    15161517        """ 
    15171518        if self.parent != None: 
     
    15381539            self.popUpMenu.Append(id, name, msg) 
    15391540            wx.EVT_MENU(self, id, self.onResetModel) 
    1540      
     1541 
    15411542    def _reset_plotting_range(self, state): 
    15421543        """ 
     
    15571558        self.state.formfactorcombobox = self.formfactorbox.GetLabel() 
    15581559        self.state.categorycombobox = self.categorybox.GetLabel() 
    1559         
     1560 
    15601561        ## post state to fit panel 
    15611562        event = PageInfoEvent(page=self) 
    15621563        wx.PostEvent(self.parent, event) 
    1563          
     1564 
    15641565    def _save_plotting_range(self): 
    15651566        """ 
     
    15691570        self.state.qmax = self.qmax_x 
    15701571        self.state.npts = self.npts_x 
    1571              
     1572 
    15721573    def _onparamEnter_helper(self): 
    15731574        """ 
     
    15921593                                                      is_modified) 
    15931594            except: 
    1594                 pass 
     1595                logging.error(sys.exc_value) 
    15951596 
    15961597            # Here we should check whether the boundaries have been modified. 
     
    16061607                    self.qmax_x = tempmax 
    16071608                    is_modified = True 
    1608              
     1609 
    16091610                if is_2Ddata: 
    16101611                    # set mask 
    16111612                    is_modified = self._validate_Npts() 
    1612                      
     1613 
    16131614            else: 
    16141615                self.fitrange = False 
    1615                  
     1616 
    16161617            if not self.data.is_data: 
    16171618                is_modified = True 
     
    16331634                self.Refresh() 
    16341635        return is_modified 
    1635      
     1636 
    16361637    def _update_paramv_on_fit(self): 
    16371638        """ 
     
    17301731            msg += " model or Fitting range is not valid!!!  " 
    17311732            wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
    1732          
     1733 
    17331734        try: 
    17341735            self.save_current_state() 
    17351736        except: 
    1736             pass 
    1737     
     1737            logging.error(sys.exc_value) 
     1738 
    17381739        return flag 
    1739                 
     1740 
    17401741    def _is_modified(self, is_modified): 
    17411742        """ 
     
    17431744        """ 
    17441745        return is_modified 
    1745                         
     1746 
    17461747    def _reset_parameters_state(self, listtorestore, statelist): 
    17471748        """ 
     
    17821783                item_page[5].Show(item_page_info[5][0]) 
    17831784                item_page[5].SetValue(item_page_info[5][1]) 
    1784                  
     1785 
    17851786            if item_page[6] != None: 
    17861787                ## show of hide the text crtl for fitting error 
    17871788                item_page[6].Show(item_page_info[6][0]) 
    17881789                item_page[6].SetValue(item_page_info[6][1]) 
    1789                      
     1790 
    17901791    def _reset_strparam_state(self, listtorestore, statelist): 
    17911792        """ 
     
    17961797 
    17971798        listtorestore = copy.deepcopy(statelist) 
    1798          
     1799 
    17991800        for j in range(len(listtorestore)): 
    18001801            item_page = listtorestore[j] 
    18011802            item_page_info = statelist[j] 
    18021803            ##change the state of the check box for simple parameters 
    1803              
     1804 
    18041805            if item_page[0] != None: 
    18051806                item_page[0].SetValue(format_number(item_page_info[0], True)) 
     
    18131814                item_page[2].SetValue(selection) 
    18141815                self.model.setParam(param_name, selection) 
    1815                                        
     1816 
    18161817    def _copy_parameters_state(self, listtocopy, statelist): 
    18171818        """ 
    18181819        copy the state of button 
    1819          
     1820 
    18201821        :param listtocopy: the list of check button to copy 
    18211822        :param statelist: list of state object to store the current state 
    1822          
     1823 
    18231824        """ 
    18241825        if len(listtocopy) == 0: 
    18251826            return 
    1826         
     1827 
    18271828        for item in listtocopy: 
    1828    
     1829 
    18291830            checkbox_state = None 
    18301831            if item[0] != None: 
     
    18421843                error_value = item[4].GetValue() 
    18431844                error_state = item[4].IsShown() 
    1844                  
     1845 
    18451846            min_value = None 
    18461847            min_state = None 
     
    18481849                min_value = item[5].GetValue() 
    18491850                min_state = item[5].IsShown() 
    1850                  
     1851 
    18511852            max_value = None 
    18521853            max_state = None 
     
    18571858            if item[7] != None: 
    18581859                unit = item[7].GetLabel() 
    1859                 
     1860 
    18601861            statelist.append([checkbox_state, parameter_name, parameter_value, 
    18611862                              static_text, [error_state, error_value], 
    18621863                              [min_state, min_value], 
    18631864                              [max_state, max_value], unit]) 
    1864             
    1865                  
     1865 
     1866 
    18661867    def _draw_model(self, update_chisqr=True, source='model'): 
    18671868        """ 
     
    18691870        The method will use the data member from the model page 
    18701871        to build a call to the fitting perspective manager. 
    1871          
     1872 
    18721873        :param chisqr: update chisqr value [bool] 
    18731874        """ 
    18741875        wx.CallAfter(self._draw_model_after, update_chisqr, source) 
    1875          
     1876 
    18761877    def _draw_model_after(self, update_chisqr=True, source='model'): 
    18771878        """ 
     
    18791880        The method will use the data member from the model page 
    18801881        to build a call to the fitting perspective manager. 
    1881          
     1882 
    18821883        :param chisqr: update chisqr value [bool] 
    18831884        """ 
     
    19071908                                    source='model', 
    19081909                                    weight=weight) 
    1909         
     1910 
    19101911    def _on_show_sld(self, event=None): 
    19111912        """ 
     
    19221923        sld_data.name = 'SLD' 
    19231924        sld_data.axes = self.sld_axes 
    1924         self.panel = SLDPanel(self, data=sld_data, axes=self.sld_axes, id=-1) 
     1925        self.panel = SLDPanel(self, data=sld_data, axes=self.sld_axes, id= -1) 
    19251926        self.panel.ShowModal() 
    1926          
     1927 
    19271928    def _set_multfactor_combobox(self, multiplicity=10): 
    19281929        """ 
     
    19341935            self.multifactorbox.Append(str(idx), int(idx)) 
    19351936        self._hide_multfactor_combobox() 
    1936          
     1937 
    19371938    def _show_multfactor_combobox(self): 
    19381939        """ 
     
    19441945        if not self.multifactorbox.IsShown(): 
    19451946            self.multifactorbox.Show(True) 
    1946               
     1947 
    19471948    def _hide_multfactor_combobox(self): 
    19481949        """ 
     
    19541955        if self.multifactorbox.IsShown(): 
    19551956            self.multifactorbox.Hide() 
    1956      
     1957 
    19571958    def formfactor_combo_init(self): 
    19581959        """ 
     
    19601961        """ 
    19611962        self._show_combox(None) 
    1962                  
     1963 
    19631964    def _show_combox_helper(self): 
    19641965        """ 
     
    19931994                         StatusEvent(status=msg, info="error")) 
    19941995        self._populate_box(self.formfactorbox, m_list) 
    1995      
    1996     def _on_modify_cat(self, event=None):   
    1997         self._manager.parent.on_category_panel(event)   
    1998          
     1996 
     1997    def _on_modify_cat(self, event=None): 
     1998        self._manager.parent.on_category_panel(event) 
     1999 
    19992000    def _show_combox(self, event=None): 
    20002001        """ 
     
    20102011        self.Layout() 
    20112012        self.Refresh() 
    2012    
     2013 
    20132014    def _populate_box(self, combobox, list): 
    20142015        """ 
    20152016        fill combox box with dict item 
    2016          
     2017 
    20172018        :param list: contains item to fill the combox 
    20182019            item must model class 
     
    20262027                    name = model.name 
    20272028                mlist.append((name, models)) 
    2028                  
     2029 
    20292030        # Sort the models 
    20302031        mlist_sorted = sorted(mlist) 
     
    20322033            combobox.Append(item[0], item[1]) 
    20332034        return 0 
    2034      
     2035 
    20352036    def _onQrangeEnter(self, event): 
    20362037        """ 
    20372038        Check validity of value enter in the Q range field 
    2038          
     2039 
    20392040        """ 
    20402041        tcrtl = event.GetEventObject() 
     
    20882089            self.create_default_data() 
    20892090        self._draw_model() 
    2090                     
     2091 
    20912092    def _theory_qrange_enter(self, event): 
    20922093        """ 
    20932094        Check validity of value enter in the Q range field 
    20942095        """ 
    2095          
     2096 
    20962097        tcrtl = event.GetEventObject() 
    20972098        #Clear msg if previously shown. 
     
    21442145        self.create_default_data() 
    21452146        self._draw_model() 
    2146                     
     2147 
    21472148    def _on_select_model_helper(self): 
    21482149        """ 
     
    21702171            self.structurebox.Enable() 
    21712172            self.text2.Enable() 
    2172              
     2173 
    21732174        if form_factor != None: 
    21742175            # set multifactor for Mutifunctional models 
     
    21872188                    # default value 
    21882189                    m_id = 1 
    2189                      
     2190 
    21902191                self.multi_factor = self.multifactorbox.GetClientData(m_id) 
    21912192                if self.multi_factor == None: 
     
    22152216            self.show_sld_button.Hide() 
    22162217            self.multi_factor = None 
    2217                
     2218 
    22182219        s_id = self.structurebox.GetCurrentSelection() 
    22192220        struct_factor = self.structurebox.GetClientData(s_id) 
    2220          
     2221 
    22212222        if  struct_factor != None: 
    22222223            from sas.models.MultiplicationModel import MultiplicationModel 
     
    22332234        # check if model has magnetic parameters 
    22342235        if len(self.model.magnetic_params) > 0: 
    2235             self._has_magnetic = True  
     2236            self._has_magnetic = True 
    22362237        else: 
    2237             self._has_magnetic = False   
     2238            self._has_magnetic = False 
    22382239        ## post state to fit panel 
    22392240        self.state.parameters = [] 
     
    22452246        self.on_set_focus(None) 
    22462247        self.Layout() 
    2247          
     2248 
    22482249    def _validate_qrange(self, qmin_ctrl, qmax_ctrl): 
    22492250        """ 
    22502251        Verify that the Q range controls have valid values 
    22512252        and that Qmin < Qmax. 
    2252          
     2253 
    22532254        :param qmin_ctrl: text control for Qmin 
    22542255        :param qmax_ctrl: text control for Qmax 
    2255          
     2256 
    22562257        :return: True is the Q range is value, False otherwise 
    2257          
     2258 
    22582259        """ 
    22592260        qmin_validity = check_float(qmin_ctrl) 
     
    22792280                return False 
    22802281        return True 
    2281      
     2282 
    22822283    def _validate_Npts(self): 
    22832284        """ 
     
    23142315                self.Npts_fit.SetValue(str(len(index_data[index_data == True]))) 
    23152316                self.fitrange = True 
    2316              
     2317 
    23172318        return flag 
    23182319 
     
    23492350                self.Npts_fit.SetValue(str(len(index_data[index_data == True]))) 
    23502351                self.fitrange = True 
    2351              
     2352 
    23522353        return flag 
    2353      
     2354 
    23542355    def _check_value_enter(self, list, modified): 
    23552356        """ 
     
    23732374            #try: 
    23742375            name = str(item[1]) 
    2375              
     2376 
    23762377            if string.find(name, ".npts") == -1 and \ 
    23772378                                        string.find(name, ".nsigmas") == -1: 
     
    23792380                param_min = None 
    23802381                param_max = None 
    2381                 
     2382 
    23822383                ## check minimun value 
    23832384                if item[5] != None and item[5] != "": 
     
    23882389                                if numpy.isfinite(param_min): 
    23892390                                    item[2].SetValue(format_number(param_min)) 
    2390                              
     2391 
    23912392                            item[5].SetBackgroundColour(wx.WHITE) 
    23922393                            item[2].SetBackgroundColour(wx.WHITE) 
    2393                                             
     2394 
    23942395                        except: 
    23952396                            msg = "Wrong fit parameter range entered" 
     
    24062407                                if numpy.isfinite(param_max): 
    24072408                                    item[2].SetValue(format_number(param_max)) 
    2408                              
     2409 
    24092410                            item[6].SetBackgroundColour(wx.WHITE) 
    24102411                            item[2].SetBackgroundColour(wx.WHITE) 
     
    24152416                            raise ValueError, msg 
    24162417                        is_modified = True 
    2417                  
     2418 
    24182419                if param_min != None and param_max != None: 
    24192420                    if not self._validate_qrange(item[5], item[6]): 
     
    24222423                        wx.PostEvent(self._manager.parent, 
    24232424                                     StatusEvent(status=msg)) 
    2424                  
     2425 
    24252426                if name in self.model.details.keys(): 
    24262427                    self.model.details[name][1:3] = param_min, param_max 
     
    24432444                msg = "Wrong Fit parameter value entered " 
    24442445                wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
    2445                  
     2446 
    24462447        return is_modified 
    2447          
     2448 
    24482449    def _set_dipers_Param(self, event): 
    24492450        """ 
     
    24642465 
    24652466        self._reset_dispersity() 
    2466      
     2467 
    24672468        if self.model == None: 
    24682469            self.model_disp.Hide() 
     
    24722473        if self.enable_disp.GetValue(): 
    24732474            ## layout for model containing no dispersity parameters 
    2474              
     2475 
    24752476            self.disp_list = self.model.getDispParamList() 
    2476               
     2477 
    24772478            if len(self.disp_list) == 0 and len(self.disp_cb_dict) == 0: 
    24782479                self._layout_sizer_noDipers() 
     
    24822483        else: 
    24832484            self.sizer4_4.Clear(True) 
    2484              
     2485 
    24852486        ## post state to fit panel 
    24862487        self.save_current_state() 
     
    24942495        self.Layout() 
    24952496        self.Refresh() 
    2496            
     2497 
    24972498    def _layout_sizer_noDipers(self): 
    24982499        """ 
     
    25042505        self.fixed_param = [] 
    25052506        self.orientation_params_disp = [] 
    2506          
     2507 
    25072508        self.sizer4_4.Clear(True) 
    25082509        text = "No polydispersity available for this model" 
     
    25122513        self.sizer4_4.Layout() 
    25132514        self.sizer4.Layout() 
    2514      
     2515 
    25152516    def _reset_dispersity(self): 
    25162517        """ 
     
    25252526                if item in self.param_toFit: 
    25262527                    self.param_toFit.remove(item) 
    2527           
     2528 
    25282529        self.fittable_param = [] 
    25292530        self.fixed_param = [] 
     
    25312532        self.values = {} 
    25322533        self.weights = {} 
    2533        
     2534 
    25342535        from sas.models.dispersion_models import GaussianDispersion 
    25352536        if len(self.disp_cb_dict) == 0: 
     
    25432544                # Go back to Gaussian model (with 0 pts) 
    25442545                disp_model = GaussianDispersion() 
    2545                 
     2546 
    25462547                self._disp_obj_dict[p] = disp_model 
    25472548                # Set the new model as the dispersion object 
     
    25502551                    self.model.set_dispersion(p, disp_model) 
    25512552                except: 
    2552  
    2553                     pass 
     2553                    logging.error(sys.exc_value) 
    25542554 
    25552555        ## save state into 
     
    25572557        self.Layout() 
    25582558        self.Refresh() 
    2559                    
     2559 
    25602560    def _on_select_Disp(self, event): 
    25612561        """ 
     
    25702570        event = PageInfoEvent(page=self) 
    25712571        wx.PostEvent(self.parent, event) 
    2572          
     2572 
    25732573        self.sizer4_4.Layout() 
    25742574        self.sizer4.Layout() 
    25752575        self.SetupScrolling() 
    2576      
     2576 
    25772577    def _on_disp_func(self, event=None): 
    25782578        """ 
    25792579        Select a distribution function for the polydispersion 
    2580          
     2580 
    25812581        :Param event: ComboBox event 
    25822582        """ 
     
    25942594            disp_name = disp_box.GetValue() 
    25952595            dispersity = disp_box.GetClientData(selection) 
    2596      
     2596 
    25972597            #disp_model =  GaussianDispersion() 
    25982598            disp_model = dispersity() 
     
    26122612                self.model.set_dispersion(param_name, disp_model) 
    26132613                self.state._disp_obj_dict[name1] = disp_model 
    2614   
     2614 
    26152615                value1 = str(format_number(self.model.getParam(name1), True)) 
    26162616                value2 = str(format_number(self.model.getParam(name2))) 
     
    26402640            for item in self.fixed_param: 
    26412641                if item[1] == name2: 
    2642                     item[2].SetValue(value2)  
     2642                    item[2].SetValue(value2) 
    26432643                    # Disable Npts for array 
    26442644                    if disp_name.lower() == "array": 
     
    26532653                    else: 
    26542654                        item[2].Enable() 
    2655                  
     2655 
    26562656            # Make sure the check box updated when all checked 
    26572657            if self.cb1.GetValue(): 
     
    26742674            wx.PostEvent(self._manager.parent, 
    26752675                         StatusEvent(status=msg, info="error")) 
    2676          
     2676 
    26772677    def _set_array_disp(self, name=None, disp=None): 
    26782678        """ 
    26792679        Set array dispersion 
    2680          
     2680 
    26812681        :param name: name of the parameter for the dispersion to be set 
    26822682        :param disp: the polydisperion object 
     
    26952695        self._default_save_location = os.path.dirname(path) 
    26962696        if self._manager != None: 
    2697             self._manager.parent._default_save_location =\ 
     2697            self._manager.parent._default_save_location = \ 
    26982698                             self._default_save_location 
    26992699 
    27002700        basename = os.path.basename(path) 
    27012701        values, weights = self.read_file(path) 
    2702          
     2702 
    27032703        # If any of the two arrays is empty, notify the user that we won't 
    27042704        # proceed 
     
    27132713                                    values=values, weights=weights) 
    27142714        return basename 
    2715      
     2715 
    27162716    def _set_array_disp_model(self, name=None, disp=None, 
    27172717                              values=[], weights=[]): 
    27182718        """ 
    27192719        Set array dispersion model 
    2720          
     2720 
    27212721        :param name: name of the parameter for the dispersion to be set 
    27222722        :param disp: the polydisperion object 
     
    27472747        self.state.model._persistency_dict[name.split('.')[0]] = \ 
    27482748                                        [values, weights] 
    2749                                          
     2749 
    27502750    def _del_array_values(self, name=None): 
    27512751        """ 
    27522752        Reset array dispersion 
    2753          
     2753 
    27542754        :param name: name of the parameter for the dispersion to be set 
    27552755        """ 
     
    27642764            del self.state.model._persistency_dict[name.split('.')[0]] 
    27652765        except: 
    2766             pass 
    2767                                              
     2766            logging.error(sys.exc_value) 
     2767 
    27682768    def _lay_out(self): 
    27692769        """ 
    27702770        returns self.Layout 
    2771          
     2771 
    27722772        :Note: Mac seems to like this better when self. 
    27732773            Layout is called after fitting. 
     
    27762776        self.Layout() 
    27772777        return 
    2778      
     2778 
    27792779    def _sleep4sec(self): 
    27802780        """ 
     
    27852785        if ON_MAC == True: 
    27862786            time.sleep(1) 
    2787              
     2787 
    27882788    def _find_polyfunc_selection(self, disp_func=None): 
    27892789        """ 
    27902790        FInd Comboox selection from disp_func 
    2791          
     2791 
    27922792        :param disp_function: dispersion distr. function 
    27932793        """ 
     
    28032803        except: 
    28042804            return 3 
    2805                              
     2805 
    28062806    def on_reset_clicked(self, event): 
    28072807        """ 
     
    28152815            flag = False 
    28162816            return 
    2817              
     2817 
    28182818        elif self.data.__class__.__name__ == "Data2D": 
    28192819            data_min = 0 
     
    28212821            y = max(math.fabs(self.data.ymin), math.fabs(self.data.ymax)) 
    28222822            self.qmin_x = data_min 
    2823             self.qmax_x = math.sqrt(x*x + y*y) 
     2823            self.qmax_x = math.sqrt(x * x + y * y) 
    28242824            #self.data.mask = numpy.ones(len(self.data.data),dtype=bool) 
    28252825            # check smearing 
     
    28312831                else: 
    28322832                    flag = True 
    2833                      
     2833 
    28342834        elif self.data == None: 
    28352835            self.qmin_x = _QMIN_DEFAULT 
     
    28372837            self.num_points = _NPTS_DEFAULT 
    28382838            self.state.npts = self.num_points 
    2839              
     2839 
    28402840        elif self.data.__class__.__name__ != "Data2D": 
    28412841            self.qmin_x = min(self.data.x) 
     
    28532853        else: 
    28542854            flag = False 
    2855              
     2855 
    28562856        if flag == False: 
    28572857            msg = "Cannot Plot :Must enter a number!!!  " 
     
    28702870        self.state.qmin = self.qmin_x 
    28712871        self.state.qmax = self.qmax_x 
    2872          
     2872 
    28732873        #reset the q range values 
    28742874        self._reset_plotting_range(self.state) 
    28752875        self._draw_model() 
    2876          
     2876 
    28772877    def select_log(self, event): 
    28782878        """ 
     
    28832883        """ 
    28842884        Get the images of the plots corresponding this panel for report 
    2885          
     2885 
    28862886        : return graphs: list of figures 
    28872887        : Need Move to guiframe 
     
    29072907                        # append to the list 
    29082908                        graphs.append(item2.figure) 
    2909                         canvases.append(item2.canvas)   
     2909                        canvases.append(item2.canvas) 
    29102910            except: 
    29112911                # Not for control panels 
    2912                 pass 
     2912                logging.error(sys.exc_value) 
    29132913        # Make sure the resduals plot goes to the last 
    29142914        if res_item != None: 
     
    29212921        """ 
    29222922        Function called when 'Help' button is pressed next to model 
    2923         of interest.  This calls DocumentationWindow from  
     2923        of interest.  This calls DocumentationWindow from 
    29242924        documentation_window.py. It will load the top level of the model 
    29252925        help documenation sphinx generated html if no model is presented. 
     
    29302930        accessible because webbrowser module does not pass anything after 
    29312931        the # to the browser. 
    2932          
     2932 
    29332933        :param evt: on Help Button pressed event 
    29342934        """ 
     
    29392939            name = self.formfactorbox.GetValue() 
    29402940 
    2941         if self.model != None:   
    2942             _docspath='user/models/model_functions.html#' + name 
     2941        if self.model != None: 
     2942            _docspath = 'user/models/model_functions.html#' + name 
    29432943            _doc_viewer = DocumentationWindow(self, -1, _docspath, name + "Help") 
    29442944        else: 
     
    29562956        behaved model is encountered which has no description then it will 
    29572957        give the message that none is available. 
    2958          
     2958 
    29592959        :param evt: on Description Button pressed event 
    29602960        """ 
     
    29782978            wx.MessageBox(msg, info) 
    29792979 
    2980     def _on_mag_help(self, event):     
    2981         """ 
    2982         Bring up Magnetic Angle definition bmp image whenever the ? button  
    2983         is clicked. Calls DocumentationWindow with the path of the location  
    2984         within the documentation tree (after /doc/ ....". When using old  
     2980    def _on_mag_help(self, event): 
     2981        """ 
     2982        Bring up Magnetic Angle definition bmp image whenever the ? button 
     2983        is clicked. Calls DocumentationWindow with the path of the location 
     2984        within the documentation tree (after /doc/ ....". When using old 
    29852985        versions of Wx (i.e. before 2.9 and therefore not part of release 
    29862986        versions distributed via installer) it brings up an image viewer 
    2987         box which allows the user to click through the rest of the images in  
     2987        box which allows the user to click through the rest of the images in 
    29882988        the directory.  Not ideal but probably better than alternative which 
    2989         would bring up the entire discussion of how magnetic models work?  
     2989        would bring up the entire discussion of how magnetic models work? 
    29902990        Specially since it is not likely to be accessed.  The normal release 
    29912991        versions bring up the normal image box. 
    2992          
     2992 
    29932993        :param evt: Triggers on clicking ? in Magnetic Angles? box 
    29942994        """ 
    2995          
     2995 
    29962996        _TreeLocation = "_images/M_angles_pic.bmp" 
    29972997        _doc_viewer = DocumentationWindow(self, -1, \ 
    2998              _TreeLocation,"Magnetic Angle Defintions") 
    2999   
    3000     def _on_mag_on(self, event):     
     2998             _TreeLocation, "Magnetic Angle Defintions") 
     2999 
     3000    def _on_mag_on(self, event): 
    30013001        """ 
    30023002        Magnetic Parameters ON/OFF 
     
    30193019                    #reset mag value to zero fo safety 
    30203020                    self.model.setParam(key, 0.0) 
    3021                      
    3022         self.Show(False)     
     3021 
     3022        self.Show(False) 
    30233023        self.set_model_param_sizer(self.model) 
    30243024        #self._set_sizer_dispersion()  
     
    30263026        self.SetupScrolling() 
    30273027        self.Show(True) 
    3028              
     3028 
    30293029    def on_pd_help_clicked(self, event): 
    30303030        """ 
    3031         Bring up Polydispersity Documentation whenever the ? button is clicked.  
     3031        Bring up Polydispersity Documentation whenever the ? button is clicked. 
    30323032        Calls DocumentationWindow with the path of the location within the 
    3033         documentation tree (after /doc/ ....".  Note that when using old  
    3034         versions of Wx (before 2.9) and thus not the release version of  
    3035         istallers, the help comes up at the top level of the file as  
     3033        documentation tree (after /doc/ ....".  Note that when using old 
     3034        versions of Wx (before 2.9) and thus not the release version of 
     3035        istallers, the help comes up at the top level of the file as 
    30363036        webbrowser does not pass anything past the # to the browser when it is 
    30373037        running "file:///...." 
    3038          
     3038 
    30393039        :param evt: Triggers on clicking ? in polydispersity box 
    30403040        """ 
    3041                  
     3041 
    30423042        _TreeLocation = "user/perspectives/fitting/fitting_help.html" 
    30433043        _TreeLocation += "#polydispersity-distributions" 
    30443044        _doc_viewer = DocumentationWindow(self, -1, \ 
    3045              _TreeLocation,"Polydispersity Help") 
    3046          
     3045             _TreeLocation, "Polydispersity Help") 
     3046 
    30473047    def on_left_down(self, event): 
    30483048        """ 
     
    30593059        # make event free 
    30603060        event.Skip() 
    3061          
     3061 
    30623062    def get_copy(self): 
    30633063        """ 
     
    30683068        self._copy_info(flag) 
    30693069        return flag 
    3070              
     3070 
    30713071    def get_copy_params(self): 
    30723072        """ 
     
    30763076        # Do it if params exist 
    30773077        if  self.parameters != []: 
    3078              
     3078 
    30793079            # go through the parameters 
    30803080            strings = self._get_copy_helper(self.parameters, 
    30813081                                           self.orientation_params) 
    30823082            content += strings 
    3083              
     3083 
    30843084            # go through the fittables 
    30853085            strings = self._get_copy_helper(self.fittable_param, 
     
    30913091                                           self.orientation_params_disp) 
    30923092            content += strings 
    3093                  
     3093 
    30943094            # go through the str params 
    30953095            strings = self._get_copy_helper(self.str_parameters, 
     
    31243124                content += param[1] #parameter name 
    31253125                content += tab 
    3126                 content += param[1]+"_err" 
     3126                content += param[1] + "_err" 
    31273127                content += tab 
    31283128 
     
    31323132            for param in self.parameters: 
    31333133                content += param[2].GetValue() #value 
    3134                 content +=tab 
     3134                content += tab 
    31353135                content += param[4].GetValue() #error 
    3136                 content +=tab 
     3136                content += tab 
    31373137 
    31383138            return content 
     
    31703170 
    31713171            for index, param in enumerate(self.parameters): 
    3172                 content += param[1].replace('_','\_') #parameter name 
     3172                content += param[1].replace('_', '\_') #parameter name 
    31733173                content += ' & ' 
    3174                 content += param[1].replace('_','\_')+"\_err" 
    3175                 if index < len(self.parameters)-1: 
     3174                content += param[1].replace('_', '\_') + "\_err" 
     3175                if index < len(self.parameters) - 1: 
    31763176                    content += ' & ' 
    31773177            content += '\\\\ \\hline' 
     
    31833183                content += ' & ' 
    31843184                content += param[4].GetValue() #parameter error 
    3185                 if index < len(self.parameters)-1: 
     3185                if index < len(self.parameters) - 1: 
    31863186                    content += ' & ' 
    31873187            content += '\\\\ \\hline' 
     
    32063206            return True 
    32073207        return None 
    3208      
     3208 
    32093209    def _get_copy_helper(self, param, orient_param): 
    32103210        """ 
    32113211        Helping get value and name of the params 
    3212          
     3212 
    32133213        : param param:  parameters 
    32143214        : param orient_param = oritational params 
     
    32263226                    disfunc = str(item[7].GetValue()) 
    32273227            except: 
    3228                 pass 
    3229              
     3228                logging.error(sys.exc_value) 
     3229 
    32303230            # 2D 
    32313231            if self.data.__class__.__name__ == "Data2D": 
     
    32493249            # add to the content 
    32503250            if disfunc != '': 
    3251                  
     3251 
    32523252                disfunc = ',' + disfunc 
    32533253            # Need to support array func for copy/paste 
     
    32613261                        disfunc += ' ' + str(weight) 
    32623262            except: 
    3263                 pass 
     3263                logging.error(sys.exc_value) 
    32643264            content += name + ',' + str(check) + ',' + value + disfunc + ':' 
    32653265 
    32663266        return content 
    3267     
     3267 
    32683268    def get_clipboard(self): 
    32693269        """ 
     
    32853285            wx.TheClipboard.Close() 
    32863286        return text 
    3287      
     3287 
    32883288    def get_paste(self): 
    32893289        """ 
     
    32943294        self._copy_info(flag) 
    32953295        return flag 
    3296          
     3296 
    32973297    def get_paste_params(self, text=''): 
    32983298        """ 
     
    33233323                    val = [float(a_val) for a_val in array_values[1:]] 
    33243324                    weit = [float(a_weit) for a_weit in array_weights[1:]] 
    3325                      
     3325 
    33263326                    context[name].append(val) 
    33273327                    context[name].append(weit) 
     
    33463346            self._get_paste_helper(self.fixed_param, 
    33473347                                   self.orientation_params_disp, context) 
    3348              
     3348 
    33493349            # go through the str params 
    33503350            self._get_paste_helper(self.str_parameters, 
    33513351                                   self.orientation_params, context) 
    3352                  
     3352 
    33533353            return True 
    33543354        return None 
    3355      
     3355 
    33563356    def _get_paste_helper(self, param, orient_param, content): 
    33573357        """ 
    33583358        Helping set values of the params 
    3359          
     3359 
    33603360        : param param:  parameters 
    33613361        : param orient_param: oritational params 
     
    33853385                            fun_val = self.model.fun_list[content[name][1]] 
    33863386                            self.model.setParam(name, fun_val) 
    3387                      
     3387 
    33883388                    value = content[name][1:] 
    33893389                    self._paste_poly_help(item, value) 
     
    34313431                        if is_true != None: 
    34323432                            item[0].SetValue(is_true) 
    3433                          
     3433 
    34343434    def _paste_poly_help(self, item, value): 
    34353435        """ 
    34363436        Helps get paste for poly function 
    3437          
     3437 
    34383438        :param item: Gui param items 
    34393439        :param value: the values for parameter ctrols 
     
    34623462                            is_array = True 
    34633463                except: 
    3464                     pass 
     3464                    logging.error(sys.exc_value) 
    34653465                if not is_array: 
    34663466                    self._disp_obj_dict[name] = disp_model 
     
    34753475                                            [self.state.values, 
    34763476                                             self.state.weights] 
    3477                           
     3477 
    34783478            except: 
     3479                logging.error(sys.exc_value) 
    34793480                print "Error in BasePage._paste_poly_help: %s" % sys.exc_value 
    3480      
     3481 
    34813482    def _set_disp_array_cb(self, item): 
    34823483        """ 
     
    34923493        item[6].SetValue('') 
    34933494        item[6].Enable(False) 
    3494          
     3495 
    34953496    def update_pinhole_smear(self): 
    34963497        """ 
     
    35183519            if not os.path.isfile(categorization_file): 
    35193520                categorization_file = CategoryInstaller.get_default_file() 
    3520             cat_file = open(categorization_file, 'rb')                            
     3521            cat_file = open(categorization_file, 'rb') 
    35213522            self.master_category_dict = json.load(cat_file) 
    35223523            self._regenerate_model_dict() 
     
    35313532    def _regenerate_model_dict(self): 
    35323533        """ 
    3533         regenerates self.by_model_dict which has each model name as the  
     3534        regenerates self.by_model_dict which has each model name as the 
    35343535        key and the list of categories belonging to that model 
    35353536        along with the enabled mapping 
     
    35413542                self.by_model_dict[model].append(category) 
    35423543                self.model_enabled_dict[model] = enabled 
    3543      
     3544 
    35443545    def _populate_listbox(self): 
    35453546        """ 
     
    35533554        if not uncat_str in cat_list: 
    35543555            cat_list.append(uncat_str) 
    3555          
     3556 
    35563557        for category in cat_list: 
    35573558            if category != '': 
     
    35613562            self.categorybox.SetSelection(0) 
    35623563        else: 
    3563             self.categorybox.SetSelection( \ 
     3564            self.categorybox.SetSelection(\ 
    35643565                self.categorybox.GetSelection()) 
    35653566 
     
    35833584 
    35843585        else: 
    3585             for (model,enabled) in sorted(self.master_category_dict[category], 
    3586                                       key = lambda name: name[0]): 
     3586            for (model, enabled) in sorted(self.master_category_dict[category], 
     3587                                      key=lambda name: name[0]): 
    35873588                if(enabled): 
    35883589                    self.model_box.Append(model) 
     
    36173618        hint = "toggle view of model from 1D to 2D  or 2D to 1D" 
    36183619        self.model_view.SetToolTipString(hint) 
    3619          
     3620 
    36203621        cat_set_box = wx.StaticBox(self, -1, 'Category') 
    36213622        sizer_cat_box = wx.StaticBoxSizer(cat_set_box, wx.HORIZONTAL) 
    36223623        sizer_cat_box.SetMinSize((200, 50)) 
    36233624        self.categorybox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 
    3624         self.categorybox.SetToolTip( wx.ToolTip("Select a Category/Type") ) 
     3625        self.categorybox.SetToolTip(wx.ToolTip("Select a Category/Type")) 
    36253626        self._populate_listbox() 
    36263627        wx.EVT_COMBOBOX(self.categorybox, -1, self._show_combox) 
     
    36313632        #self.struct_rbutton = wx.RadioButton(self, -1, "Structure Factor ") 
    36323633        #self.plugin_rbutton = wx.RadioButton(self, -1, "Uncategorized") 
    3633                  
     3634 
    36343635        #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
    36353636        #                   id=self.shape_rbutton.GetId()) 
     
    36413642        #                    id=self.plugin_rbutton.GetId()) 
    36423643        #MAC needs SetValue 
    3643          
     3644 
    36443645        show_cat_button = wx.Button(self, -1, "Modify") 
    36453646        cat_tip = "Modify model categories \n" 
    36463647        cat_tip += "(also accessible from the menu bar)." 
    3647         show_cat_button.SetToolTip( wx.ToolTip(cat_tip) ) 
     3648        show_cat_button.SetToolTip(wx.ToolTip(cat_tip)) 
    36483649        show_cat_button.Bind(wx.EVT_BUTTON, self._on_modify_cat) 
    36493650        sizer_cat_box.Add(self.categorybox, 1, wx.RIGHT, 3) 
    3650         sizer_cat_box.Add((10,10)) 
     3651        sizer_cat_box.Add((10, 10)) 
    36513652        sizer_cat_box.Add(show_cat_button) 
    36523653        #self.shape_rbutton.SetValue(True) 
    3653        
     3654 
    36543655        sizer_radiobutton = wx.GridSizer(2, 2, 5, 5) 
    3655          
     3656 
    36563657 
    36573658        #sizer_radiobutton.Add(self.shape_rbutton) 
    36583659        #sizer_radiobutton.Add(self.shape_indep_rbutton) 
    3659         sizer_radiobutton.Add((5,5)) 
     3660        sizer_radiobutton.Add((5, 5)) 
    36603661        sizer_radiobutton.Add(self.model_view, 1, wx.RIGHT, 5) 
    36613662        #sizer_radiobutton.Add(self.plugin_rbutton) 
    36623663        #sizer_radiobutton.Add(self.struct_rbutton) 
    36633664#        sizer_radiobutton.Add((5,5)) 
    3664         sizer_radiobutton.Add(self.model_help, 1, wx.RIGHT|wx.LEFT, 5) 
     3665        sizer_radiobutton.Add(self.model_help, 1, wx.RIGHT | wx.LEFT, 5) 
    36653666#        sizer_radiobutton.Add((5,5)) 
    36663667        sizer_radiobutton.Add(self.model_func, 1, wx.RIGHT, 5) 
     
    36693670        sizer_selection = wx.BoxSizer(wx.HORIZONTAL) 
    36703671        mutifactor_selection = wx.BoxSizer(wx.HORIZONTAL) 
    3671          
     3672 
    36723673        self.text1 = wx.StaticText(self, -1, "") 
    36733674        self.text2 = wx.StaticText(self, -1, "P(Q)*S(Q)") 
     
    36783679 
    36793680        self.formfactorbox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 
    3680         self.formfactorbox.SetToolTip( wx.ToolTip("Select a Model") ) 
     3681        self.formfactorbox.SetToolTip(wx.ToolTip("Select a Model")) 
    36813682        if self.model != None: 
    36823683            self.formfactorbox.SetValue(self.model.name) 
     
    36923693            print "_set_model_sizer_selection: disabled." 
    36933694            #self._set_model_sizer_selection(self.model) 
    3694          
     3695 
    36953696        sizer_selection.Add(self.text1) 
    36963697        sizer_selection.Add((10, 5)) 
     
    37003701        sizer_selection.Add((5, 5)) 
    37013702        sizer_selection.Add(self.structurebox) 
    3702         
     3703 
    37033704        mutifactor_selection.Add((13, 5)) 
    37043705        mutifactor_selection.Add(self.mutifactor_text) 
     
    37143715        boxsizer1.Add((10, 10)) 
    37153716        boxsizer1.Add(mutifactor_selection) 
    3716          
     3717 
    37173718        self._set_multfactor_combobox() 
    37183719        self.multifactorbox.SetSelection(1) 
     
    37203721        sizer.Add(boxsizer1, 0, wx.EXPAND | wx.ALL, 10) 
    37213722        sizer.Layout() 
    3722          
     3723 
    37233724    def on_smear_helper(self, update=False): 
    37243725        """ 
    37253726        Help for onSmear if implemented 
    3726          
     3727 
    37273728        :param update: force or not to update 
    37283729        """ 
     
    37333734    def onSmear(self, event): 
    37343735        """ 
    3735         Create a smear object if implemented  
     3736        Create a smear object if implemented 
    37363737        """ 
    37373738    def onPinholeSmear(self, event): 
Note: See TracChangeset for help on using the changeset viewer.