Changeset f668101 in sasview for src/sas/sasgui/perspectives


Ignore:
Timestamp:
Dec 7, 2016 9:16:33 AM (7 years ago)
Author:
jhbakker
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, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
c6728e1
Parents:
1cad8a4 (diff), 5231948 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into Jurtest

Location:
src/sas/sasgui/perspectives
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/calculator/model_editor.py

    rec72ceb ra08b89b  
    2828import math 
    2929import re 
     30import logging 
    3031from wx.py.editwindow import EditWindow 
    3132from sas.sasgui.guiframe.documentation_window import DocumentationWindow 
     
    388389            wx.PostEvent(self.parent.parent, StatusEvent(status=msg, 
    389390                                                         info=info)) 
    390         else: 
    391             raise 
    392391 
    393392    def on_help(self, event): 
     
    512511        fill the current combobox with the operator 
    513512        """ 
    514         operator_list = [' +', ' *'] 
     513        operator_list = ['+', '*'] 
    515514        for oper in operator_list: 
    516515            pos = self._operator_choice.Append(str(oper)) 
    517             self._operator_choice.SetClientData(pos, str(oper.strip())) 
     516            self._operator_choice.SetClientData(pos, str(oper)) 
    518517        self._operator_choice.SetSelection(0) 
    519518 
     
    684683        #title name [string] 
    685684        name_txt = wx.StaticText(self, -1, 'Function Name : ') 
    686         overwrite_cb = wx.CheckBox(self, -1, "Overwrite?", (10, 10)) 
     685        overwrite_cb = wx.CheckBox(self, -1, "Overwrite existing plugin model of this name?", (10, 10)) 
    687686        overwrite_cb.SetValue(False) 
    688687        overwrite_cb.SetToolTipString("Overwrite it if already exists?") 
    689688        wx.EVT_CHECKBOX(self, overwrite_cb.GetId(), self.on_over_cb) 
    690         #overwrite_cb.Show(False) 
    691689        self.name_tcl = wx.TextCtrl(self, -1, size=(PANEL_WIDTH * 3 / 5, -1)) 
    692690        self.name_tcl.Bind(wx.EVT_TEXT_ENTER, self.on_change_name) 
    693         self.name_tcl.SetValue('MyFunction') 
     691        self.name_tcl.SetValue('') 
    694692        self.name_tcl.SetFont(self.font) 
    695693        hint_name = "Unique Model Function Name." 
     
    947945        # Sort out the errors if occur 
    948946        # First check for valid python name then if the name already exists 
    949         if not re.match('^[A-Za-z0-9_]*$', name): 
    950             msg = "not a valid python name. Name must include only alpha \n" 
    951             msg += "numeric or underline characters and no spaces" 
     947        if not name or not bool(re.match('^[A-Za-z0-9_]*$', name)): 
     948            msg = '"%s" '%name 
     949            msg += "is not a valid model name. Name must not be empty and \n" 
     950            msg += "may include only alpha numeric or underline characters \n" 
     951            msg += "and no spaces" 
    952952        elif self.check_name(): 
    953953            description = self.desc_tcl.GetValue() 
     
    966966                        result, msg = None, "error building model" 
    967967                        check_err = "\n"+traceback.format_exc(limit=2) 
    968  
    969                     # Modified compiling test, as it will fail for sasmodels.sasview_model class 
    970                     # Should add a test to check that the class is correctly built  
    971                     # by sasview_model.make_class_from_file? 
    972 #                    try:  
    973 #                        tr_msg = _compile_file(self.fname) 
    974 #                        msg = str(tr_msg.__str__()) 
    975 #                        # Compile error 
    976 #                        if msg: 
    977 #                            msg.replace("  ", "\n") 
    978 #                            msg += "\nCompiling Failed" 
    979 #                            try: 
    980 #                                # try to remove pyc file if exists 
    981 #                                _delete_file(self.fname) 
    982 #                                _delete_file(self.fname + "c") 
    983 #                            except: 
    984 #                                pass 
    985 #                    except: 
    986 #                        pass 
    987968                else: 
    988969                    msg = "Error: The func(x) must 'return' a value at least.\n" 
     
    1002983                exec "from %s import Model" % name 
    1003984            except: 
    1004                 pass 
    1005 #            except: 
    1006 #                msg = 'new model fails to import in python' 
    1007 #                try: 
    1008 #                    # try to remove pyc file if exists 
    1009 #                    _delete_file(self.fname + "c") 
    1010 #                except: 
    1011 #                    pass 
    1012 # 
    1013 # And also need to test if model runs             
    1014 #        if self.base != None and not msg: 
    1015 #            try: 
    1016 #                Model().run(0.01) 
    1017 #            except: 
    1018 #                msg = "new model fails on run method:" 
    1019 #                _, value, _ = sys.exc_info() 
    1020 #                msg += "in %s:\n%s\n" % (name, value) 
    1021 #                try: 
    1022 #                    # try to remove pyc file if exists 
    1023 #                    _delete_file(self.fname + "c") 
    1024 #                except: 
    1025 #                    pass 
     985                logging.error(sys.exc_value) 
     986 
    1026987        # Prepare the messagebox 
    1027988        if msg: 
     
    11911152 
    11921153        _TreeLocation = "user/sasgui/perspectives/fitting/fitting_help.html" 
    1193         _PageAnchor = "#custom-model-editor" 
     1154        _PageAnchor = "#new-plugin-model" 
    11941155        _doc_viewer = DocumentationWindow(self, -1, _TreeLocation, _PageAnchor, 
    1195                                           "Custom Model Editor Help") 
     1156                                          "Plugin Model Editor Help") 
    11961157 
    11971158    def on_close(self, event): 
     
    12301191 
    12311192## Templates for custom models 
    1232 #CUSTOM_TEMPLATE = """ 
    1233 #from sas.models.pluginmodel import Model1DPlugin 
    1234 #from math import * 
    1235 #import os 
    1236 #import sys 
    1237 #import numpy 
    1238 ##import scipy? 
    1239 #class Model(Model1DPlugin): 
    1240 #    name = basename without extension of __file__ 
    1241 #    def __init__(self): 
    1242 #        Model1DPlugin.__init__(self, name=self.name) 
    1243 #        #set name same as file name 
    1244 #        #self.params here 
    1245 #        self.description = "%s" 
    1246 #        self.set_details() 
    1247 #    def function(self, x=0.0%s): 
    1248 #        #local params here 
    1249 #        #function here 
    1250 #""" 
    12511193 
    12521194CUSTOM_TEMPLATE = """ 
     
    14191361 
    14201362    def _clone(self, obj): 
     1363        import copy 
    14211364        obj.params     = copy.deepcopy(self.params) 
    14221365        obj.description     = copy.deepcopy(self.description) 
  • src/sas/sasgui/perspectives/fitting/basepage.py

    r55db501 rf668101  
    1919 
    2020from sas.sasgui.guiframe.panel_base import PanelBase 
    21 from sas.sasgui.guiframe.utils import format_number, check_float, IdList, check_int 
     21from sas.sasgui.guiframe.utils import format_number, check_float, IdList, \ 
     22    check_int 
    2223from sas.sasgui.guiframe.events import PanelOnFocusEvent 
    2324from sas.sasgui.guiframe.events import StatusEvent 
     
    4243_QMAX_DEFAULT = 0.5 
    4344_NPTS_DEFAULT = 50 
    44 #Control panel width 
     45# Control panel width 
    4546if sys.platform.count("win32") > 0: 
    4647    PANEL_WIDTH = 450 
     
    5758    This class provide general structure of  fitpanel page 
    5859    """ 
    59     ## Internal name for the AUI manager 
     60    # Internal name for the AUI manager 
    6061    window_name = "Fit Page" 
    61     ## Title to appear on top of the window 
     62    # Title to appear on top of the window 
    6263    window_caption = "Fit Page " 
    6364 
     
    7576        PanelBase.__init__(self, parent) 
    7677        self.SetupScrolling() 
    77         #Set window's font size 
     78        # Set window's font size 
    7879        self.SetWindowVariant(variant=FONT_VARIANT) 
    7980        self.SetBackgroundColour(color) 
    8081 
    8182        self._ids = iter(self._id_pool) 
    82         ## parent of the page 
     83        # parent of the page 
    8384        self.parent = parent 
    84         ## manager is the fitting plugin 
    85         ## owner of the page (fitting plugin) 
     85        # manager is the fitting plugin 
     86        # owner of the page (fitting plugin) 
    8687        self.event_owner = None 
    87         ## current model 
     88        # current model 
    8889        self.model = None 
    8990        self.m_name = None 
    9091        self.index_model = None 
    9192        self.panel = None 
    92         ## data 
     93        # data 
    9394        self.data = None 
    94         #list of available data 
     95        # list of available data 
    9596        self.data_list = [] 
    9697        self.mask = None 
    9798        self.uid = wx.NewId() 
    9899        self.graph_id = None 
    99         #Q range for data set 
     100        # Q range for data set 
    100101        self.qmin_data_set = numpy.inf 
    101102        self.qmax_data_set = None 
    102103        self.npts_data_set = 0 
    103         ## Q range 
     104        # Q range 
    104105        self.qmin = None 
    105106        self.qmax = None 
     
    107108        self.qmin_x = _QMIN_DEFAULT 
    108109        self.npts_x = _NPTS_DEFAULT 
    109         ## total number of point: float 
     110        # total number of point: float 
    110111        self.npts = None 
    111112        self.num_points = None 
    112         ## smear default 
     113        # smear default 
    113114        self.current_smearer = None 
    114         ## 2D smear accuracy default 
     115        # 2D smear accuracy default 
    115116        self.smear2d_accuracy = 'Low' 
    116         ## slit smear: 
     117        # slit smear: 
    117118        self.dxl = None 
    118119        self.dxw = None 
    119         ## pinhole smear 
     120        # pinhole smear 
    120121        self.dx_min = None 
    121122        self.dx_max = None 
    122         ##semar attrbs 
     123        # smear attrbs 
    123124        self.enable_smearer = None 
    124125        self.disable_smearer = None 
    125126        self.pinhole_smearer = None 
    126127        self.slit_smearer = None 
    127         ##weigth attrbs 
     128        # weight attrbs 
    128129        self.dI_noweight = None 
    129130        self.dI_didata = None 
    130131        self.dI_sqrdata = None 
    131132        self.dI_idata = None 
    132         ##other attrbs 
     133        # other attrbs 
    133134        self.dq_l = None 
    134135        self.dq_r = None 
     
    150151        self.disp_cb_dict = {} 
    151152 
    152         #self.state = PageState(parent=parent) 
    153         ## dictionary containing list of models 
     153        # self.state = PageState(parent=parent) 
     154        # dictionary containing list of models 
    154155        self.model_list_box = {} 
    155156 
    156         ## Data member to store the dispersion object created 
     157        # Data member to store the dispersion object created 
    157158        self._disp_obj_dict = {} 
    158         ## selected parameters to apply dispersion 
     159        # selected parameters to apply dispersion 
    159160        self.disp_cb_dict = {} 
    160         ## smearer object 
     161        # smearer object 
    161162        self.enable2D = False 
    162163        self._has_magnetic = False 
     
    166167        self.structurebox = None 
    167168        self.categorybox = None 
    168         ##list of model parameters. each item must have same length 
    169         ## each item related to a given parameters 
    170         ##[cb state, name, value, "+/-", error of fit, min, max , units] 
     169        # list of model parameters. each item must have same length 
     170        # each item related to a given parameters 
     171        # [cb state, name, value, "+/-", error of fit, min, max , units] 
    171172        self.parameters = [] 
    172173        # non-fittable parameter whose value is astring 
    173174        self.str_parameters = [] 
    174         ## list of parameters to fit , must be like self.parameters 
     175        # list of parameters to fit , must be like self.parameters 
    175176        self.param_toFit = [] 
    176         ## list of looking like parameters but with non fittable parameters info 
     177        # list of looking like parameters but with non fittable parameters info 
    177178        self.fixed_param = [] 
    178         ## list of looking like parameters but with  fittable parameters info 
     179        # list of looking like parameters but with  fittable parameters info 
    179180        self.fittable_param = [] 
    180         ##list of dispersion parameters 
     181        # list of dispersion parameters 
    181182        self.disp_list = [] 
    182183        self.disp_name = "" 
    183184 
    184         ## list of orientation parameters 
     185        # list of orientation parameters 
    185186        self.orientation_params = [] 
    186187        self.orientation_params_disp = [] 
     
    189190#       and this - commenting out on 4/8/2014 by PDB.  Remove once clear 
    190191#       it is pointless. 
    191 #        if self.model != None: 
     192#        if self.model is not None: 
    192193#            self.disp_list = self.model.getDispParamList() 
    193194        self.temp_multi_functional = False 
    194         ##enable model 2D draw 
     195        # enable model 2D draw 
    195196        self.enable2D = False 
    196         ## check that the fit range is correct to plot the model again 
     197        # check that the fit range is correct to plot the model again 
    197198        self.fitrange = True 
    198         ## Create memento to save the current state 
     199        # Create memento to save the current state 
    199200        self.state = PageState(parent=self.parent, 
    200201                               model=self.model, data=self.data) 
    201         ## flag to determine if state has change 
     202        # flag to determine if state has change 
    202203        self.state_change = False 
    203         ## save customized array 
     204        # save customized array 
    204205        self.values = {}   # type: Dict[str, List[float, ...]] 
    205206        self.weights = {}   # type: Dict[str, List[float, ...]] 
    206         ## retrieve saved state 
     207        # retrieve saved state 
    207208        self.number_saved_state = 0 
    208         ## dictionary of saved state 
     209        # dictionary of saved state 
    209210        self.saved_states = {} 
    210         ## Create context menu for page 
     211        # Create context menu for page 
    211212        self.popUpMenu = wx.Menu() 
    212213 
     
    221222        self.popUpMenu.AppendSeparator() 
    222223 
    223         ## Default locations 
     224        # Default locations 
    224225        self._default_save_location = os.getcwd() 
    225         ## save initial state on context menu 
    226         #self.onSave(event=None) 
     226        # save initial state on context menu 
     227        # self.onSave(event=None) 
    227228        self.Bind(wx.EVT_CONTEXT_MENU, self.onContextMenu) 
    228229 
     
    230231        self.Bind(wx.EVT_LEFT_DOWN, self.on_left_down) 
    231232 
    232         ## create the basic structure of the panel with empty sizer 
     233        # create the basic structure of the panel with empty sizer 
    233234        self.define_page_structure() 
    234         ## drawing Initial dispersion parameters sizer 
     235        # drawing Initial dispersion parameters sizer 
    235236        self.set_dispers_sizer() 
    236237 
    237         ## layout 
     238        # layout 
    238239        self.set_layout() 
    239240 
     
    261262                    self._create_default_1d_data() 
    262263 
    263             if self.model != None: 
     264            if self.model is not None: 
    264265                if not self.data.is_data: 
    265                     self._manager.page_finder[self.uid].set_fit_data(data=\ 
    266                                                                 [self.data]) 
     266                    self._manager.page_finder[self.uid].set_fit_data( 
     267                        data=[self.data]) 
    267268            self.on_smear_helper(update=True) 
    268269            self.state.enable_smearer = self.enable_smearer.GetValue() 
     
    330331        self.data.id = str(self.uid) + " data" 
    331332        self.data.group_id = str(self.uid) + " Model2D" 
    332         ## Default values 
     333        # Default values 
    333334        self.data.detector.append(Detector()) 
    334335        index = len(self.data.detector) - 1 
     
    347348        x = numpy.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True) 
    348349        y = numpy.linspace(start=ymin, stop=ymax, num=qstep, endpoint=True) 
    349         ## use data info instead 
     350        # use data info instead 
    350351        new_x = numpy.tile(x, (len(y), 1)) 
    351352        new_y = numpy.tile(y, (len(x), 1)) 
     
    388389        Update menu1 on cliking the page tap 
    389390        """ 
    390         if self._manager.menu1 != None: 
    391             chain_menu = self._manager.menu1.FindItemById(\ 
     391        if self._manager.menu1 is not None: 
     392            chain_menu = self._manager.menu1.FindItemById( 
    392393                                                   self._manager.id_reset_flag) 
    393394            chain_menu.Enable(self.batch_on) 
    394395            sim_menu = self._manager.menu1.FindItemById(self._manager.id_simfit) 
    395396            flag = self.data.is_data\ 
    396                             and (self.model != None) 
     397                            and (self.model is not None) 
    397398            sim_menu.Enable(not self.batch_on and flag) 
    398399            batch_menu = \ 
     
    535536        fill sizer containing dispersity info 
    536537        """ 
    537         #print "==== entering set_dispers_sizer ===" 
     538        # print "==== entering set_dispers_sizer ===" 
    538539        self.sizer4.Clear(True) 
    539540        name = "Polydispersity and Orientational Distribution" 
     
    541542        box_description.SetForegroundColour(wx.BLUE) 
    542543        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 
    543         #---------------------------------------------------- 
     544        # ---------------------------------------------------- 
    544545        self.disable_disp = wx.RadioButton(self, wx.ID_ANY, 'Off', (10, 10), 
    545546                                           style=wx.RB_GROUP) 
     
    561562        self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param, 
    562563                  id=self.enable_disp.GetId()) 
    563         #MAC needs SetValue 
     564        # MAC needs SetValue 
    564565        self.disable_disp.SetValue(True) 
    565566        sizer_dispersion = wx.BoxSizer(wx.HORIZONTAL) 
     
    573574        sizer_dispersion.Add(self.disp_help_bt) 
    574575 
    575         ## fill a sizer for dispersion 
     576        # fill a sizer for dispersion 
    576577        boxsizer1.Add(sizer_dispersion, 0, 
    577578                      wx.TOP|wx.BOTTOM|wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 
     
    580581 
    581582        boxsizer1.Add(self.sizer4_4) 
    582         #----------------------------------------------------- 
     583        # ----------------------------------------------------- 
    583584        self.sizer4.Add(boxsizer1, 0, wx.EXPAND | wx.ALL, 10) 
    584585        self.sizer4_4.Layout() 
     
    587588 
    588589        self.Refresh() 
    589         ## saving the state of enable dispersity button 
     590        # saving the state of enable dispersity button 
    590591        self.state.enable_disp = self.enable_disp.GetValue() 
    591592        self.state.disable_disp = self.disable_disp.GetValue() 
     
    597598        """ 
    598599        menu = event.GetEventObject() 
    599         ## post help message for the selected model 
     600        # post help message for the selected model 
    600601        msg = menu.GetHelpString(event.GetId()) 
    601602        msg += " reloaded" 
     
    604605        name = menu.GetLabel(event.GetId()) 
    605606        self._on_select_model_helper() 
    606         if self.model != None: 
     607        if self.model is not None: 
    607608            self.m_name = self.model.name 
    608609        if name in self.saved_states.keys(): 
    609610            previous_state = self.saved_states[name] 
    610             ## reset state of checkbox,textcrtl  and  regular parameters value 
     611            # reset state of checkbox,textcrtl  and  regular parameters value 
    611612 
    612613            self.reset_page(previous_state) 
     
    631632        # Ask the user the location of the file to write to. 
    632633        path = None 
    633         if self.parent != None: 
     634        if self.parent is not None: 
    634635            self._default_save_location = \ 
    635636                        self._manager.parent._default_save_location 
     
    641642            self._default_save_location = os.path.dirname(path) 
    642643            self._manager.parent._default_save_location = \ 
    643                                 self._default_save_location 
     644                self._default_save_location 
    644645        else: 
    645646            return None 
     
    648649        # Make sure the ext included in the file name 
    649650        fName = os.path.splitext(path)[0] + extens 
    650         #the manager write the state into file 
     651        # the manager write the state into file 
    651652        self._manager.save_fit_state(filepath=fName, fitstate=new_state) 
    652653        return new_state 
     
    656657        Copy Parameter values to the clipboad 
    657658        """ 
    658         if event != None: 
     659        if event is not None: 
    659660            event.Skip() 
    660661        # It seems MAC needs wxCallAfter 
     
    672673        Paste Parameter values to the panel if possible 
    673674        """ 
    674         #if event != None: 
     675        # if event is not None: 
    675676        #    event.Skip() 
    676677        # It seems MAC needs wxCallAfter for the setvalues 
     
    678679        wx.CallAfter(self.get_paste) 
    679680        # messages depending on the flag 
    680         #self._copy_info(True) 
     681        # self._copy_info(True) 
    681682 
    682683    def _copy_info(self, flag): 
     
    687688        """ 
    688689        # messages depending on the flag 
    689         if flag == None: 
     690        if flag is None: 
    690691            msg = " Parameter values are copied to the clipboard..." 
    691692            infor = 'warning' 
     
    715716        save history of the data and model 
    716717        """ 
    717         if self.model == None: 
     718        if self.model is None: 
    718719            msg = "Can not bookmark; Please select Data and Model first..." 
    719720            wx.MessageBox(msg, 'Info') 
     
    721722        self.save_current_state() 
    722723        new_state = self.state.clone() 
    723         ##Add model state on context menu 
     724        # Add model state on context menu 
    724725        self.number_saved_state += 1 
    725726        current_time, current_date = self._get_time_stamp() 
    726         #name= self.model.name+"[%g]"%self.number_saved_state 
     727        # name= self.model.name+"[%g]"%self.number_saved_state 
    727728        name = "Fitting: %g]" % self.number_saved_state 
    728729        name += self.model.__class__.__name__ 
     
    730731        self.saved_states[name] = new_state 
    731732 
    732         ## Add item in the context menu 
     733        # Add item in the context menu 
    733734        msg = "Model saved at %s on %s" % (current_time, current_date) 
    734         ## post help message for the selected model 
     735        # post help message for the selected model 
    735736        msg += " Saved! right click on this page to retrieve this model" 
    736737        wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
     
    766767        """ 
    767768        try: 
    768             if path == None: 
     769            if path is None: 
    769770                status = " Selected Distribution was not loaded: %s" % path 
    770771                wx.PostEvent(self._manager.parent, 
     
    801802        Store current state 
    802803        """ 
    803         ## save model option 
    804         if self.model != None: 
     804        # save model option 
     805        if self.model is not None: 
    805806            self.disp_list = self.model.getDispParamList() 
    806807            self.state.disp_list = copy.deepcopy(self.disp_list) 
    807808            self.state.model = self.model.clone() 
    808809 
    809             #model combobox: complex code because of mac's silent error 
    810             if self.structurebox != None: 
     810            # model combobox: complex code because of mac's silent error 
     811            if self.structurebox is not None: 
    811812                if self.structurebox.IsShown(): 
    812813                    self.state.structurecombobox = 'None' 
    813814                    s_select = self.structurebox.GetSelection() 
    814815                    if s_select > 0: 
    815                         self.state.structurecombobox = self.structurebox.\ 
    816                         GetString(s_select) 
    817             if self.formfactorbox != None: 
     816                        self.state.structurecombobox = \ 
     817                            self.structurebox.GetString(s_select) 
     818            if self.formfactorbox is not None: 
    818819                f_select = self.formfactorbox.GetSelection() 
    819820                if f_select > 0: 
    820                     self.state.formfactorcombobox = self.formfactorbox.\ 
    821                     GetString(f_select) 
    822         if self.categorybox != None: 
     821                    self.state.formfactorcombobox = \ 
     822                        self.formfactorbox.GetString(f_select) 
     823        if self.categorybox is not None: 
    823824            cb_select = self.categorybox.GetSelection() 
    824825            if cb_select > 0: 
    825                 self.state.categorycombobox = self.categorybox.\ 
    826                 GetString(cb_select) 
     826                self.state.categorycombobox = \ 
     827                    self.categorybox.GetString(cb_select) 
    827828 
    828829        self.state.enable2D = copy.deepcopy(self.enable2D) 
    829830        self.state.values = copy.deepcopy(self.values) 
    830831        self.state.weights = copy.deepcopy(self.weights) 
    831         ## save data 
     832        # save data 
    832833        self.state.data = copy.deepcopy(self.data) 
    833834        self.state.qmax_x = self.qmax_x 
     
    864865            self.state.values = copy.deepcopy(self.values) 
    865866            self.state.weights = copy.deepcopy(self.weights) 
    866         ## save plotting range 
     867        # save plotting range 
    867868        self._save_plotting_range() 
    868869 
     
    874875        self.state.str_parameters = [] 
    875876 
    876         ## save checkbutton state and txtcrtl values 
     877        # save checkbutton state and txtcrtl values 
    877878        self._copy_parameters_state(self.str_parameters, 
    878879                                    self.state.str_parameters) 
     
    886887                                    self.state.fittable_param) 
    887888        self._copy_parameters_state(self.fixed_param, self.state.fixed_param) 
    888         #save chisqr 
     889        # save chisqr 
    889890        self.state.tcChi = self.tcChi.GetValue() 
    890891 
     
    893894        Store current state for fit_page 
    894895        """ 
    895         ## save model option 
    896         if self.model != None: 
     896        # save model option 
     897        if self.model is not None: 
    897898            self.disp_list = self.model.getDispParamList() 
    898899            self.state.disp_list = copy.deepcopy(self.disp_list) 
     
    902903        self.state.values = copy.deepcopy(self.values) 
    903904        self.state.weights = copy.deepcopy(self.weights) 
    904         ## save data 
     905        # save data 
    905906        self.state.data = copy.deepcopy(self.data) 
    906907 
     
    923924        self.state.dI_sqrdata = copy.deepcopy(self.dI_sqrdata.GetValue()) 
    924925        self.state.dI_idata = copy.deepcopy(self.dI_idata.GetValue()) 
    925         if hasattr(self, "disp_box") and self.disp_box != None: 
     926        if hasattr(self, "disp_box") and self.disp_box is not None: 
    926927            self.state.disp_box = self.disp_box.GetCurrentSelection() 
    927928 
    928929            if len(self.disp_cb_dict) > 0: 
    929930                for k, v in self.disp_cb_dict.iteritems(): 
    930                     if v == None: 
     931                    if v is None: 
    931932                        self.state.disp_cb_dict[k] = v 
    932933                    else: 
     
    942943            self.state.weights = copy.deepcopy(self.weights) 
    943944 
    944         ## save plotting range 
     945        # save plotting range 
    945946        self._save_plotting_range() 
    946947 
    947         ## save checkbutton state and txtcrtl values 
     948        # save checkbutton state and txtcrtl values 
    948949        self._copy_parameters_state(self.orientation_params, 
    949950                                    self.state.orientation_params) 
     
    964965            msg = "Please load Data and select Model to start..." 
    965966            wx.MessageBox(msg, 'Info') 
    966             return  True 
     967            return True 
    967968 
    968969    def set_model_state(self, state): 
     
    973974        self.disp_list = state.disp_list 
    974975 
    975         ## fill model combobox 
     976        # fill model combobox 
    976977        self._show_combox_helper() 
    977         #select the current model 
     978        # select the current model 
    978979        try: 
    979980            # to support older version 
     
    10141015        self.structurebox.SetSelection(structfactor_pos) 
    10151016 
    1016         if state.multi_factor != None: 
     1017        if state.multi_factor is not None: 
    10171018            self.multifactorbox.SetSelection(state.multi_factor) 
    10181019 
    1019         ## reset state of checkbox,textcrtl  and  regular parameters value 
     1020        # reset state of checkbox,textcrtl  and  regular parameters value 
    10201021        self._reset_parameters_state(self.orientation_params_disp, 
    10211022                                     state.orientation_params_disp) 
     
    10251026                                     state.str_parameters) 
    10261027        self._reset_parameters_state(self.parameters, state.parameters) 
    1027         ## display dispersion info layer 
     1028        # display dispersion info layer 
    10281029        self.enable_disp.SetValue(state.enable_disp) 
    10291030        self.disable_disp.SetValue(state.disable_disp) 
    10301031 
    1031         if hasattr(self, "disp_box") and self.disp_box != None: 
     1032        if hasattr(self, "disp_box") and self.disp_box is not None: 
    10321033            self.disp_box.SetSelection(state.disp_box) 
    10331034            n = self.disp_box.GetCurrentSelection() 
     
    10411042 
    10421043                    if hasattr(self.disp_cb_dict[item], "SetValue"): 
    1043                         self.disp_cb_dict[item].SetValue(\ 
     1044                        self.disp_cb_dict[item].SetValue( 
    10441045                                                    state.disp_cb_dict[item]) 
    10451046                        # Create the dispersion objects 
    10461047                        disp_model = POLYDISPERSITY_MODELS['array']() 
    10471048                        if hasattr(state, "values") and \ 
    1048                                  self.disp_cb_dict[item].GetValue() == True: 
     1049                                 self.disp_cb_dict[item].GetValue() is True: 
    10491050                            if len(state.values) > 0: 
    10501051                                self.values = state.values 
     
    10571058                        self._disp_obj_dict[item] = disp_model 
    10581059                        # Set the new model as the dispersion object 
    1059                         #for the selected parameter 
     1060                        # for the selected parameter 
    10601061                        self.model.set_dispersion(item, disp_model) 
    10611062 
     
    10671068                for item in keys: 
    10681069                    if item in self.disp_list and \ 
    1069                         not item in self.model.details: 
     1070                            item not in self.model.details: 
    10701071                        self.model.details[item] = ["", None, None] 
    10711072                self.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 
    10721073                self.state.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 
    1073         ## smearing info  restore 
     1074        # smearing info  restore 
    10741075        if hasattr(self, "enable_smearer"): 
    1075             ## set smearing value whether or not the data 
    1076             #contain the smearing info 
     1076            # set smearing value whether or not the data 
     1077            # contain the smearing info 
    10771078            self.enable_smearer.SetValue(state.enable_smearer) 
    10781079            self.disable_smearer.SetValue(state.disable_smearer) 
     
    10861087        self.dI_idata.SetValue(state.dI_idata) 
    10871088 
    1088         ## we have two more options for smearing 
     1089        # we have two more options for smearing 
    10891090        if self.pinhole_smearer.GetValue(): 
    10901091            self.onPinholeSmear(event=None) 
     
    10921093            self.onSlitSmear(event=None) 
    10931094 
    1094         ## reset state of checkbox,textcrtl  and dispersity parameters value 
     1095        # reset state of checkbox,textcrtl  and dispersity parameters value 
    10951096        self._reset_parameters_state(self.fittable_param, state.fittable_param) 
    10961097        self._reset_parameters_state(self.fixed_param, state.fixed_param) 
    10971098 
    1098         ## draw the model with previous parameters value 
     1099        # draw the model with previous parameters value 
    10991100        self._onparamEnter_helper() 
    11001101        self.select_param(event=None) 
    1101         #Save state_fit 
     1102        # Save state_fit 
    11021103        self.save_current_state_fit() 
    11031104        self._lay_out() 
     
    11131114                if state.formfactorcombobox in list_item: 
    11141115                    return self.categorybox.Items.index(key) 
     1116        return 0 
    11151117 
    11161118    def reset_page_helper(self, state): 
     
    11231125            state of the graphic interface 
    11241126        """ 
    1125         if state == None: 
     1127        if state is None: 
    11261128            return 
    11271129        # set data, etc. from the state 
     
    11321134        data = state.data 
    11331135 
    1134         if data == None: 
     1136        if data is None: 
    11351137            data_min = state.qmin 
    11361138            data_max = state.qmax 
     
    11561158        self.disp_list = state.disp_list 
    11571159 
    1158         ## set the state of the radio box 
    1159         #self.shape_rbutton.SetValue(state.shape_rbutton) 
    1160         #self.shape_indep_rbutton.SetValue(state.shape_indep_rbutton) 
    1161         #self.struct_rbutton.SetValue(state.struct_rbutton) 
    1162         #self.plugin_rbutton.SetValue(state.plugin_rbutton) 
    1163  
    1164         ## fill model combobox 
     1160        # fill model combobox 
    11651161        self._show_combox_helper() 
    1166         #select the current model 
     1162        # select the current model 
    11671163        try: 
    11681164            # to support older version 
    11691165            category_pos = int(state.categorycombobox) 
    11701166        except: 
    1171             state.formfactorcombobox = unicode(state.formfactorcombobox.lower()) 
     1167            state.formfactorcombobox = state.formfactorcombobox.lower() 
     1168            state.formfactorcombobox = \ 
     1169                state.formfactorcombobox.replace('model', '') 
     1170            state.formfactorcombobox = unicode(state.formfactorcombobox) 
    11721171            state.categorycombobox = unicode(state.categorycombobox) 
    1173             category_pos = 0 
    11741172            if state.categorycombobox in self.categorybox.Items: 
    11751173                category_pos = self.categorybox.Items.index( 
     
    11941192        self.formfactorbox.Select(formfactor_pos) 
    11951193 
     1194        structfactor_pos = 0 
    11961195        try: 
    11971196            # to support older version 
     
    11991198        except: 
    12001199            if state.structurecombobox is not None: 
    1201                 structfactor_pos = 0 
    12021200                state.structurecombobox = unicode(state.structurecombobox) 
    12031201                for ind_struct in range(self.structurebox.GetCount()): 
    12041202                    if self.structurebox.GetString(ind_struct) == \ 
    1205                                                         (state.structurecombobox): 
     1203                                                    (state.structurecombobox): 
    12061204                        structfactor_pos = int(ind_struct) 
    12071205                        break 
     
    12091207        self.structurebox.SetSelection(structfactor_pos) 
    12101208 
    1211         if state.multi_factor != None: 
     1209        if state.multi_factor is not None: 
    12121210            self.multifactorbox.SetSelection(state.multi_factor) 
    12131211 
    1214         #draw the panel according to the new model parameter 
     1212        # draw the panel according to the new model parameter 
    12151213        self._on_select_model(event=None) 
    12161214 
    12171215        # take care of 2D button 
    1218         if data == None and self.model_view.IsEnabled(): 
     1216        if data is None and self.model_view.IsEnabled(): 
    12191217            if self.enable2D: 
    12201218                self.model_view.SetLabel("2D Mode") 
     
    12221220                self.model_view.SetLabel("1D Mode") 
    12231221 
    1224         ## set the select all check box to the a given state 
    1225         self.cb1.SetValue(state.cb1) 
    1226  
    1227         ## reset state of checkbox,textcrtl  and  regular parameters value 
     1222        # reset state of checkbox,textcrtl  and  regular parameters value 
    12281223        self._reset_parameters_state(self.orientation_params_disp, 
    12291224                                     state.orientation_params_disp) 
     
    12331228                                     state.str_parameters) 
    12341229        self._reset_parameters_state(self.parameters, state.parameters) 
    1235         ## display dispersion info layer 
     1230        # display dispersion info layer 
    12361231        self.enable_disp.SetValue(state.enable_disp) 
    12371232        self.disable_disp.SetValue(state.disable_disp) 
     
    12411236            self._set_dipers_Param(event=None) 
    12421237            self._reset_page_disp_helper(state) 
    1243         ##plotting range restore 
     1238        # plotting range restore 
    12441239        self._reset_plotting_range(state) 
    1245         ## smearing info  restore 
     1240        # smearing info  restore 
    12461241        if hasattr(self, "enable_smearer"): 
    1247             ## set smearing value whether or not the data 
    1248             #contain the smearing info 
     1242            # set smearing value whether or not the data 
     1243            # contain the smearing info 
    12491244            self.enable_smearer.SetValue(state.enable_smearer) 
    12501245            self.disable_smearer.SetValue(state.disable_smearer) 
     
    12641259            self.dI_idata.SetValue(False) 
    12651260 
    1266         ## we have two more options for smearing 
     1261        # we have two more options for smearing 
    12671262        if self.pinhole_smearer.GetValue(): 
    12681263            self.dx_min = state.dx_min 
    12691264            self.dx_max = state.dx_max 
    1270             if self.dx_min != None: 
     1265            if self.dx_min is not None: 
    12711266                self.smear_pinhole_min.SetValue(str(self.dx_min)) 
    1272             if self.dx_max != None: 
     1267            if self.dx_max is not None: 
    12731268                self.smear_pinhole_max.SetValue(str(self.dx_max)) 
    12741269            self.onPinholeSmear(event=None) 
     
    12761271            self.dxl = state.dxl 
    12771272            self.dxw = state.dxw 
    1278             if self.dxl != None: 
     1273            if self.dxl is not None: 
    12791274                self.smear_slit_height.SetValue(str(self.dxl)) 
    1280             if self.dxw != None: 
     1275            if self.dxw is not None: 
    12811276                self.smear_slit_width.SetValue(str(self.dxw)) 
    12821277            else: 
     
    12841279            self.onSlitSmear(event=None) 
    12851280 
    1286         ## reset state of checkbox,textcrtl  and dispersity parameters value 
     1281        # reset state of checkbox,textcrtl  and dispersity parameters value 
    12871282        self._reset_parameters_state(self.fittable_param, state.fittable_param) 
    12881283        self._reset_parameters_state(self.fixed_param, state.fixed_param) 
    12891284 
    1290         ## draw the model with previous parameters value 
     1285        # draw the model with previous parameters value 
    12911286        self._onparamEnter_helper() 
    1292         #reset the value of chisqr when not consistent with the value computed 
     1287        # reset the value of chisqr when not consistent with the value computed 
    12931288        self.tcChi.SetValue(str(self.state.tcChi)) 
    1294         ## reset context menu items 
     1289        # reset context menu items 
    12951290        self._reset_context_menu() 
    12961291 
    1297         ## set the value of the current state to the state given as parameter 
     1292        # set the value of the current state to the state given as parameter 
    12981293        self.state = state.clone() 
    12991294        self.state.m_name = self.m_name 
     
    13061301        for item in keys: 
    13071302            if item in self.disp_list and \ 
    1308                 not item in self.model.details: 
     1303                            item not in self.model.details: 
    13091304                self.model.details[item] = ["", None, None] 
    1310         #for k,v in self.state.disp_cb_dict.iteritems(): 
     1305        # for k,v in self.state.disp_cb_dict.iteritems(): 
    13111306        self.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 
    13121307        self.state.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 
     
    13151310 
    13161311        for key, disp_type in state._disp_obj_dict.iteritems(): 
    1317             #disp_model = disp 
     1312            # disp_model = disp 
    13181313            disp_model = POLYDISPERSITY_MODELS[disp_type]() 
    13191314            self._disp_obj_dict[key] = disp_model 
     
    13241319                self.model.set_dispersion(param_name, disp_model) 
    13251320                self.model._persistency_dict[key] = \ 
    1326                                  [state.values, state.weights] 
     1321                    [state.values, state.weights] 
    13271322            except Exception: 
    13281323                logging.error(traceback.format_exc()) 
    13291324            selection = self._find_polyfunc_selection(disp_model) 
    13301325            for list in self.fittable_param: 
    1331                 if list[1] == key and list[7] != None: 
     1326                if list[1] == key and list[7] is not None: 
    13321327                    list[7].SetSelection(selection) 
    13331328                    # For the array disp_model, set the values and weights 
     
    13621357        open a dialog file to selected the customized dispersity 
    13631358        """ 
    1364         if self.parent != None: 
     1359        if self.parent is not None: 
    13651360            self._default_save_location = \ 
    13661361                        self._manager.parent.get_save_location() 
     
    13811376        for name, _ in self.state.saved_states.iteritems(): 
    13821377            self.number_saved_state += 1 
    1383             ## Add item in the context menu 
     1378            # Add item in the context menu 
    13841379            wx_id = ids.next() 
    13851380            msg = 'Save model and state %g' % self.number_saved_state 
     
    13981393        save radiobutton containing the type model that can be selected 
    13991394        """ 
    1400         #self.state.shape_rbutton = self.shape_rbutton.GetValue() 
    1401         #self.state.shape_indep_rbutton = self.shape_indep_rbutton.GetValue() 
    1402         #self.state.struct_rbutton = self.struct_rbutton.GetValue() 
    1403         #self.state.plugin_rbutton = self.plugin_rbutton.GetValue() 
     1395        # self.state.shape_rbutton = self.shape_rbutton.GetValue() 
     1396        # self.state.shape_indep_rbutton = self.shape_indep_rbutton.GetValue() 
     1397        # self.state.struct_rbutton = self.struct_rbutton.GetValue() 
     1398        # self.state.plugin_rbutton = self.plugin_rbutton.GetValue() 
    14041399        self.state.structurecombobox = self.structurebox.GetLabel() 
    14051400        self.state.formfactorcombobox = self.formfactorbox.GetLabel() 
    14061401        self.state.categorycombobox = self.categorybox.GetLabel() 
    14071402 
    1408         ## post state to fit panel 
     1403        # post state to fit panel 
    14091404        event = PageInfoEvent(page=self) 
    14101405        wx.PostEvent(self.parent, event) 
     
    14181413        self.state.npts = self.npts_x 
    14191414 
    1420     def _onparamEnter_helper(self,is_modified = False): 
     1415    def _onparamEnter_helper(self, is_modified=False): 
    14211416        """ 
    14221417        check if values entered by the user are changed and valid to replot 
     
    14241419        """ 
    14251420        # Flag to register when a parameter has changed. 
    1426         #is_modified = False 
     1421        # is_modified = False 
    14271422        self.fitrange = True 
    14281423        is_2Ddata = False 
    1429         #self._undo.Enable(True) 
     1424        # self._undo.Enable(True) 
    14301425        # check if 2d data 
    14311426        if self.data.__class__.__name__ == "Data2D": 
    14321427            is_2Ddata = True 
    1433         if self.model != None: 
    1434             #Either we get a is_modified = True passed in because 
    1435             #_update_paramv_on_fit() has been called already or 
     1428        if self.model is not None: 
     1429            # Either we get a is_modified = True passed in because 
     1430            # _update_paramv_on_fit() has been called already or 
    14361431            # we need to check here ourselves. 
    14371432            if not is_modified: 
     
    14601455                self.fitrange = False 
    14611456 
    1462             if not self.data.is_data: 
    1463                 is_modified = True 
    1464  
    1465             ## if any value is modify draw model with new value 
     1457            # if any value is modify draw model with new value 
    14661458            if not self.fitrange: 
    1467                 #self.btFit.Disable() 
     1459                # self.btFit.Disable() 
    14681460                if is_2Ddata: 
    14691461                    self.btEditMask.Disable() 
     
    14781470                self._draw_model() 
    14791471                self.Refresh() 
     1472 
     1473        # logging.info("is_modified flag set to %g",is_modified) 
    14801474        return is_modified 
    14811475 
     
    14841478        make sure that update param values just before the fitting 
    14851479        """ 
    1486         #flag for qmin qmax check values 
     1480        # flag for qmin qmax check values 
    14871481        flag = True 
    14881482        self.fitrange = True 
    14891483        is_modified = False 
    14901484 
    1491         #wx.PostEvent(self._manager.parent, StatusEvent(status=" \ 
    1492         #updating ... ",type="update")) 
    1493  
    1494         ##So make sure that update param values on_Fit. 
    1495         #self._undo.Enable(True) 
    1496         if self.model != None: 
     1485        # wx.PostEvent(self._manager.parent, StatusEvent(status=" \ 
     1486        # updating ... ",type="update")) 
     1487 
     1488        # So make sure that update param values on_Fit. 
     1489        # self._undo.Enable(True) 
     1490        if self.model is not None: 
    14971491            if self.Npts_total.GetValue() != self.Npts_fit.GetValue(): 
    14981492                if not self.data.is_data: 
    1499                     self._manager.page_finder[self.uid].set_fit_data(data=\ 
    1500                                                                 [self.data]) 
    1501             ##Check the values 
     1493                    self._manager.page_finder[self.uid].set_fit_data( 
     1494                        data=[self.data]) 
     1495            # Check the values 
    15021496            is_modified = (self._check_value_enter(self.fittable_param) 
    1503                             or self._check_value_enter(self.fixed_param) 
    1504                             or self._check_value_enter(self.parameters)) 
     1497                           or self._check_value_enter(self.fixed_param) 
     1498                           or self._check_value_enter(self.parameters)) 
    15051499 
    15061500            # If qmin and qmax have been modified, update qmin and qmax and 
     
    15431537                                              enable_smearer=enable_smearer, 
    15441538                                              draw=False) 
    1545                     if self.data != None: 
    1546                         index_data = ((self.qmin_x <= self.data.x) & \ 
     1539                    if self.data is not None: 
     1540                        index_data = ((self.qmin_x <= self.data.x) & 
    15471541                                      (self.data.x <= self.qmax_x)) 
    1548                         val = str(len(self.data.x[index_data == True])) 
     1542                        val = str(len(self.data.x[index_data is True])) 
    15491543                        self.Npts_fit.SetValue(val) 
    15501544                    else: 
     
    15661560            flag = False 
    15671561 
    1568         #For invalid q range, disable the mask editor and fit button, vs. 
     1562        # For invalid q range, disable the mask editor and fit button, vs. 
    15691563        if not self.fitrange: 
    15701564            if self._is_2D(): 
    15711565                self.btEditMask.Disable() 
    15721566        else: 
    1573             if self._is_2D() and  self.data.is_data and not self.batch_on: 
     1567            if self._is_2D() and self.data.is_data and not self.batch_on: 
    15741568                self.btEditMask.Enable(True) 
    15751569 
     
    15841578            logging.error(traceback.format_exc()) 
    15851579 
    1586         return flag,is_modified 
     1580        return flag, is_modified 
    15871581 
    15881582    def _reset_parameters_state(self, listtorestore, statelist): 
     
    15981592            item_page = listtorestore[j] 
    15991593            item_page_info = statelist[j] 
    1600             ##change the state of the check box for simple parameters 
    1601             if item_page[0] != None: 
     1594            # change the state of the check box for simple parameters 
     1595            if item_page[0] is not None: 
    16021596                item_page[0].SetValue(item_page_info[0]) 
    1603             if item_page[2] != None: 
     1597            if item_page[2] is not None: 
    16041598                item_page[2].SetValue(item_page_info[2]) 
    16051599                if item_page[2].__class__.__name__ == "ComboBox": 
     
    16071601                        fun_val = self.model.fun_list[item_page_info[2]] 
    16081602                        self.model.setParam(item_page_info[1], fun_val) 
    1609             if item_page[3] != None: 
    1610                 ## show or hide text +/- 
     1603            if item_page[3] is not None: 
     1604                # show or hide text +/- 
    16111605                if item_page_info[2]: 
    16121606                    item_page[3].Show(True) 
    16131607                else: 
    16141608                    item_page[3].Hide() 
    1615             if item_page[4] != None: 
    1616                 ## show of hide the text crtl for fitting error 
     1609            if item_page[4] is not None: 
     1610                # show of hide the text crtl for fitting error 
    16171611                if item_page_info[4][0]: 
    16181612                    item_page[4].Show(True) 
     
    16201614                else: 
    16211615                    item_page[3].Hide() 
    1622             if item_page[5] != None: 
    1623                 ## show of hide the text crtl for fitting error 
     1616            if item_page[5] is not None: 
     1617                # show of hide the text crtl for fitting error 
    16241618                item_page[5].Show(item_page_info[5][0]) 
    16251619                item_page[5].SetValue(item_page_info[5][1]) 
    16261620 
    1627             if item_page[6] != None: 
    1628                 ## show of hide the text crtl for fitting error 
     1621            if item_page[6] is not None: 
     1622                # show of hide the text crtl for fitting error 
    16291623                item_page[6].Show(item_page_info[6][0]) 
    16301624                item_page[6].SetValue(item_page_info[6][1]) 
     
    16421636            item_page = listtorestore[j] 
    16431637            item_page_info = statelist[j] 
    1644             ##change the state of the check box for simple parameters 
    1645  
    1646             if item_page[0] != None: 
     1638            # change the state of the check box for simple parameters 
     1639 
     1640            if item_page[0] is not None: 
    16471641                item_page[0].SetValue(format_number(item_page_info[0], True)) 
    16481642 
    1649             if item_page[2] != None: 
     1643            if item_page[2] is not None: 
    16501644                param_name = item_page_info[1] 
    16511645                value = item_page_info[2] 
     
    16701664 
    16711665            checkbox_state = None 
    1672             if item[0] != None: 
     1666            if item[0] is not None: 
    16731667                checkbox_state = item[0].GetValue() 
    16741668            parameter_name = item[1] 
    16751669            parameter_value = None 
    1676             if item[2] != None: 
     1670            if item[2] is not None: 
    16771671                parameter_value = item[2].GetValue() 
    16781672            static_text = None 
    1679             if item[3] != None: 
     1673            if item[3] is not None: 
    16801674                static_text = item[3].IsShown() 
    16811675            error_value = None 
    16821676            error_state = None 
    1683             if item[4] != None: 
     1677            if item[4] is not None: 
    16841678                error_value = item[4].GetValue() 
    16851679                error_state = item[4].IsShown() 
     
    16871681            min_value = None 
    16881682            min_state = None 
    1689             if item[5] != None: 
     1683            if item[5] is not None: 
    16901684                min_value = item[5].GetValue() 
    16911685                min_state = item[5].IsShown() 
     
    16931687            max_value = None 
    16941688            max_state = None 
    1695             if item[6] != None: 
     1689            if item[6] is not None: 
    16961690                max_value = item[6].GetValue() 
    16971691                max_state = item[6].IsShown() 
    16981692            unit = None 
    1699             if item[7] != None: 
     1693            if item[7] is not None: 
    17001694                unit = item[7].GetLabel() 
    17011695 
     
    17051699                              [max_state, max_value], unit]) 
    17061700 
    1707  
    17081701    def _draw_model(self, update_chisqr=True, source='model'): 
    17091702        """ 
     
    17241717        :param chisqr: update chisqr value [bool] 
    17251718        """ 
    1726         #if self.check_invalid_panel(): 
     1719        # if self.check_invalid_panel(): 
    17271720        #    return 
    1728         if self.model != None: 
     1721        if self.model is not None: 
    17291722            temp_smear = None 
    17301723            if hasattr(self, "enable_smearer"): 
     
    17381731            is_2d = self._is_2D() 
    17391732            self._manager.draw_model(self.model, 
    1740                                     data=self.data, 
    1741                                     smearer=temp_smear, 
    1742                                     qmin=float(self.qmin_x), 
    1743                                     qmax=float(self.qmax_x), 
    1744                                     page_id=self.uid, 
    1745                                     toggle_mode_on=toggle_mode_on, 
    1746                                     state=self.state, 
    1747                                     enable2D=is_2d, 
    1748                                     update_chisqr=update_chisqr, 
    1749                                     source='model', 
    1750                                     weight=weight) 
     1733                                     data=self.data, 
     1734                                     smearer=temp_smear, 
     1735                                     qmin=float(self.qmin_x), 
     1736                                     qmax=float(self.qmax_x), 
     1737                                     page_id=self.uid, 
     1738                                     toggle_mode_on=toggle_mode_on, 
     1739                                     state=self.state, 
     1740                                     enable2D=is_2d, 
     1741                                     update_chisqr=update_chisqr, 
     1742                                     source='model', 
     1743                                     weight=weight) 
    17511744 
    17521745    def _on_show_sld(self, event=None): 
     
    17581751 
    17591752        from sas.sasgui.plottools import Data1D as pf_data1d 
    1760         #from sas.sasgui.perspectives.theory.profile_dialog import SLDPanel 
     1753        # from sas.sasgui.perspectives.theory.profile_dialog import SLDPanel 
    17611754        from sas.sasgui.guiframe.local_perspectives.plotting.profile_dialog \ 
    1762         import SLDPanel 
     1755            import SLDPanel 
    17631756        sld_data = pf_data1d(x, y) 
    17641757        sld_data.name = 'SLD' 
     
    18131806        self.structurebox.Disable() 
    18141807        self.formfactorbox.Clear() 
    1815         if mod_cat == None: 
     1808        if mod_cat is None: 
    18161809            return 
    18171810        m_list = [] 
     
    18751868        """ 
    18761869        tcrtl = event.GetEventObject() 
    1877         #Clear msg if previously shown. 
     1870        # Clear msg if previously shown. 
    18781871        msg = "" 
    18791872        wx.PostEvent(self.parent, StatusEvent(status=msg)) 
     
    18941887                    tcrtl.SetBackgroundColour("pink") 
    18951888                    msg = "Model Error: wrong value entered: %s" % \ 
    1896                                     sys.exc_info()[1] 
     1889                          sys.exc_info()[1] 
    18971890                    wx.PostEvent(self.parent, StatusEvent(status=msg)) 
    18981891                    return 
     
    19021895                wx.PostEvent(self.parent, StatusEvent(status=msg)) 
    19031896                return 
    1904             #Check if # of points for theory model are valid(>0). 
    1905             if self.npts != None: 
     1897            # Check if # of points for theory model are valid(>0). 
     1898            if self.npts is not None: 
    19061899                if check_float(self.npts): 
    19071900                    temp_npts = float(self.npts.GetValue()) 
     
    19191912        wx.PostEvent(self.parent, event) 
    19201913        self.state_change = False 
    1921         #Draw the model for a different range 
     1914        # Draw the model for a different range 
    19221915        if not self.data.is_data: 
    19231916            self.create_default_data() 
     
    19301923 
    19311924        tcrtl = event.GetEventObject() 
    1932         #Clear msg if previously shown. 
     1925        # Clear msg if previously shown. 
    19331926        msg = "" 
    19341927        wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
     
    19511944                    tcrtl.SetBackgroundColour("pink") 
    19521945                    msg = "Model Error: wrong value entered: %s" % \ 
    1953                                         sys.exc_info()[1] 
     1946                          sys.exc_info()[1] 
    19541947                    wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
    19551948                    return 
     
    19591952                wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
    19601953                return 
    1961             #Check if # of points for theory model are valid(>0). 
     1954            # Check if # of points for theory model are valid(>0). 
    19621955            if self.Npts_total.IsEditable(): 
    19631956                if check_float(self.Npts_total): 
     
    19771970        wx.PostEvent(self.parent, event) 
    19781971        self.state_change = False 
    1979         #Draw the model for a different range 
     1972        # Draw the model for a different range 
    19801973        self.create_default_data() 
    19811974        self._draw_model() 
     
    19851978        call back for model selection 
    19861979        """ 
    1987         ## reset dictionary containing reference to dispersion 
     1980        # reset dictionary containing reference to dispersion 
    19881981        self._disp_obj_dict = {} 
    19891982        self.disp_cb_dict = {} 
    19901983        self.temp_multi_functional = False 
    19911984        f_id = self.formfactorbox.GetCurrentSelection() 
    1992         #For MAC 
     1985        # For MAC 
    19931986        form_factor = None 
    19941987        if f_id >= 0: 
     
    19971990        if form_factor is None or \ 
    19981991            not hasattr(form_factor, 'is_form_factor') or \ 
    1999             not form_factor.is_form_factor: 
     1992                not form_factor.is_form_factor: 
    20001993            self.structurebox.Hide() 
    20011994            self.text2.Hide() 
     
    20092002            self.text2.Enable() 
    20102003 
    2011         if form_factor != None: 
     2004        if form_factor is not None: 
    20122005            # set multifactor for Mutifunctional models 
    20132006            if form_factor.is_multiplicity_model: 
     
    20172010                self._set_multfactor_combobox(multiplicity) 
    20182011                self._show_multfactor_combobox() 
    2019                 #ToDo: this info should be called directly from the model 
     2012                # ToDo: this info should be called directly from the model 
    20202013                text = form_factor.multiplicity_info[1]  # 'No. of Shells: ' 
    20212014 
     
    20262019 
    20272020                self.multi_factor = self.multifactorbox.GetClientData(m_id) 
    2028                 if self.multi_factor == None: 
     2021                if self.multi_factor is None: 
    20292022                    self.multi_factor = 0 
    20302023                self.multifactorbox.SetSelection(m_id) 
     
    20322025                text = '' 
    20332026                if form_factor.multiplicity_info[0] == \ 
    2034                                         len(form_factor.multiplicity_info[2]): 
     2027                        len(form_factor.multiplicity_info[2]): 
    20352028                    text = form_factor.multiplicity_info[2][self.multi_factor] 
    20362029                self.mutifactor_text1.SetLabel(text) 
     
    20532046        struct_factor = self.structurebox.GetClientData(s_id) 
    20542047 
    2055         if  struct_factor != None: 
    2056             from sas.sascalc.fit.MultiplicationModel import MultiplicationModel 
     2048        if struct_factor is not None: 
     2049            from sasmodels.sasview_model import MultiplicationModel 
    20572050            self.model = MultiplicationModel(form_factor(self.multi_factor), 
    20582051                                             struct_factor()) 
     
    20602053            if len(form_factor.non_fittable) > 0: 
    20612054                self.temp_multi_functional = True 
    2062         elif form_factor != None: 
     2055        elif form_factor is not None: 
    20632056            if self.multi_factor is not None: 
    20642057                self.model = form_factor(self.multi_factor) 
     
    20752068        else: 
    20762069            self._has_magnetic = False 
    2077         ## post state to fit panel 
     2070        # post state to fit panel 
    20782071        self.state.parameters = [] 
    20792072        self.state.model = self.model 
     
    20852078        self.Layout() 
    20862079 
    2087  
    20882080    def _validate_qrange(self, qmin_ctrl, qmax_ctrl): 
    20892081        """ 
     
    21052097            qmax = float(qmax_ctrl.GetValue()) 
    21062098            if qmin < qmax: 
    2107                 #Make sure to set both colours white. 
     2099                # Make sure to set both colours white. 
    21082100                qmin_ctrl.SetBackgroundColour(wx.WHITE) 
    21092101                qmin_ctrl.Refresh() 
     
    21252117        If valid, setvalues Npts_fit otherwise post msg. 
    21262118        """ 
    2127         #default flag 
     2119        # default flag 
    21282120        flag = True 
    21292121        # Theory 
    2130         if self.data == None and self.enable2D: 
     2122        if self.data is None and self.enable2D: 
    21312123            return flag 
    21322124        for data in self.data_list: 
     
    21342126            radius = numpy.sqrt(data.qx_data * data.qx_data + 
    21352127                                data.qy_data * data.qy_data) 
    2136             #get unmasked index 
     2128            # get unmasked index 
    21372129            index_data = (float(self.qmin.GetValue()) <= radius) & \ 
    2138                             (radius <= float(self.qmax.GetValue())) 
     2130                         (radius <= float(self.qmax.GetValue())) 
    21392131            index_data = (index_data) & (data.mask) 
    21402132            index_data = (index_data) & (numpy.isfinite(data.data)) 
     
    21522144                flag = False 
    21532145            else: 
    2154                 self.Npts_fit.SetValue(str(len(index_data[index_data == True]))) 
     2146                self.Npts_fit.SetValue(str(len(index_data[index_data is True]))) 
    21552147                self.fitrange = True 
    21562148 
     
    21622154        If valid, setvalues Npts_fit otherwise post msg. 
    21632155        """ 
    2164         #default flag 
     2156        # default flag 
    21652157        flag = True 
    21662158        # Theory 
    2167         if self.data == None: 
     2159        if self.data is None: 
    21682160            return flag 
    21692161        for data in self.data_list: 
    21702162            # q value from qx and qy 
    21712163            radius = data.x 
    2172             #get unmasked index 
     2164            # get unmasked index 
    21732165            index_data = (float(self.qmin.GetValue()) <= radius) & \ 
    2174                             (radius <= float(self.qmax.GetValue())) 
     2166                         (radius <= float(self.qmax.GetValue())) 
    21752167            index_data = (index_data) & (numpy.isfinite(data.y)) 
    21762168 
     
    21872179                flag = False 
    21882180            else: 
    2189                 self.Npts_fit.SetValue(str(len(index_data[index_data == True]))) 
     2181                self.Npts_fit.SetValue(str(len(index_data[index_data is True]))) 
    21902182                self.fitrange = True 
    21912183 
     
    22072199        is_modified = False 
    22082200        for item in list: 
    2209             #skip angle parameters for 1D 
     2201            # skip angle parameters for 1D 
    22102202            if not self.enable2D and item in self.orientation_params: 
    22112203                continue 
     
    22522244                    max_ctrl.SetBackgroundColour("pink") 
    22532245                    max_ctrl.Refresh() 
    2254                     #msg = "Invalid fit range for %s: min must be smaller than max"%name 
    2255                     #wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
     2246                    # msg = "Invalid fit range for %s: min must be smaller 
     2247                    # than max"%name 
     2248                    # wx.PostEvent(self._manager.parent, 
     2249                    # StatusEvent(status=msg)) 
    22562250                    continue 
    22572251 
     
    22712265                    # The configuration has changed but it won't change the 
    22722266                    # computed curve so no need to set is_modified to True 
    2273                     #is_modified = True 
     2267                    # is_modified = True 
    22742268                    self.model.details[name][1:3] = low, high 
    22752269 
     
    22892283        Redraw the model with the default dispersity (Gaussian) 
    22902284        """ 
    2291         ## On selction if no model exists. 
    2292         if self.model == None: 
     2285        # On selction if no model exists. 
     2286        if self.model is None: 
    22932287            self.disable_disp.SetValue(True) 
    22942288            msg = "Please select a Model first..." 
     
    23002294        self._reset_dispersity() 
    23012295 
    2302         if self.model == None: 
     2296        if self.model is None: 
    23032297            self.model_disp.Hide() 
    23042298            self.sizer4_4.Clear(True) 
     
    23062300 
    23072301        if self.enable_disp.GetValue(): 
    2308             ## layout for model containing no dispersity parameters 
     2302            # layout for model containing no dispersity parameters 
    23092303 
    23102304            self.disp_list = self.model.getDispParamList() 
     
    23132307                self._layout_sizer_noDipers() 
    23142308            else: 
    2315                 ## set gaussian sizer 
     2309                # set gaussian sizer 
    23162310                self._on_select_Disp(event=None) 
    23172311        else: 
    23182312            self.sizer4_4.Clear(True) 
    23192313 
    2320         ## post state to fit panel 
     2314        # post state to fit panel 
    23212315        self.save_current_state() 
    2322         if event != None: 
     2316        if event is not None: 
    23232317            event = PageInfoEvent(page=self) 
    23242318            wx.PostEvent(self.parent, event) 
    2325         #draw the model with the current dispersity 
    2326  
    2327         #Wojtek P, Oct 8, 2016: Calling draw_model seems to be unessecary. 
    2328         #By comenting it we save an extra Iq calculation 
    2329         #self._draw_model() 
    2330  
    2331         ## Need to use FitInside again here to replace the next four lines. 
    2332         ## Otherwised polydispersity off does not resize the scrollwindow. 
    2333         ## PDB Nov 28, 2015 
     2319        # draw the model with the current dispersity 
     2320 
     2321        # Wojtek P, Oct 8, 2016: Calling draw_model seems to be unessecary. 
     2322        # By comenting it we save an extra Iq calculation 
     2323        # self._draw_model() 
     2324 
     2325        # Need to use FitInside again here to replace the next four lines. 
     2326        # Otherwised polydispersity off does not resize the scrollwindow. 
     2327        # PDB Nov 28, 2015 
    23342328        self.FitInside() 
    23352329#        self.sizer4_4.Layout() 
     
    23752369        self.weights = {} 
    23762370 
    2377         #from sas.models.dispersion_models import GaussianDispersion 
     2371        # from sas.models.dispersion_models import GaussianDispersion 
    23782372        from sasmodels.weights import GaussianDispersion 
    23792373        if len(self.disp_cb_dict) == 0: 
     
    23962390                    logging.error(traceback.format_exc()) 
    23972391 
    2398         ## save state into 
     2392        # save state into 
    23992393        self.save_current_state() 
    24002394        self.Layout() 
     
    24082402        self._set_sizer_dispersion() 
    24092403 
    2410         ## Redraw the model 
     2404        # Redraw the model 
    24112405        self._draw_model() 
    2412         #self._undo.Enable(True) 
     2406        # self._undo.Enable(True) 
    24132407        event = PageInfoEvent(page=self) 
    24142408        wx.PostEvent(self.parent, event) 
     
    24252419        """ 
    24262420        # get ready for new event 
    2427         if event != None: 
     2421        if event is not None: 
    24282422            event.Skip() 
    24292423        # Get event object 
     
    24382432            dispersity = disp_box.GetClientData(selection) 
    24392433 
    2440             #disp_model =  GaussianDispersion() 
     2434            # disp_model =  GaussianDispersion() 
    24412435            disp_model = dispersity() 
    24422436            # Get param names to reset the values of the param 
     
    24512445            else: 
    24522446                self._del_array_values(name1) 
    2453                 #self._reset_array_disp(param_name) 
     2447                # self._reset_array_disp(param_name) 
    24542448                self._disp_obj_dict[name1] = disp_model 
    24552449                self.model.set_dispersion(param_name, disp_model) 
     
    25372531        if path is None: 
    25382532            self.disp_cb_dict[name].SetValue(False) 
    2539             #self.noDisper_rbox.SetValue(True) 
     2533            # self.noDisper_rbox.SetValue(True) 
    25402534            return 
    25412535        self._default_save_location = os.path.dirname(path) 
    2542         if self._manager != None: 
     2536        if self._manager is not None: 
    25432537            self._manager.parent._default_save_location = \ 
    25442538                             self._default_save_location 
     
    25572551        wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
    25582552        self._set_array_disp_model(name=name, disp=disp, 
    2559                                     values=values, weights=weights) 
     2553                                   values=values, weights=weights) 
    25602554        return basename 
    25612555 
     
    25762570        # Store the object to make it persist outside the 
    25772571        # scope of this method 
    2578         #TODO: refactor model to clean this up? 
     2572        # TODO: refactor model to clean this up? 
    25792573        self.state.values = {} 
    25802574        self.state.weights = {} 
     
    25832577 
    25842578        # Set the new model as the dispersion object for the 
    2585         #selected parameter 
    2586         #self.model.set_dispersion(p, disp_model) 
     2579        # selected parameter 
     2580        # self.model.set_dispersion(p, disp_model) 
    25872581        # Store a reference to the weights in the model object 
    2588         #so that 
     2582        # so that 
    25892583        # it's not lost when we use the model within another thread. 
    25902584        self.state.model = self.model.clone() 
    25912585        self.model._persistency_dict[name.split('.')[0]] = \ 
    2592                                         [values, weights] 
     2586            [values, weights] 
    25932587        self.state.model._persistency_dict[name.split('.')[0]] = \ 
    2594                                         [values, weights] 
     2588            [values, weights] 
    25952589 
    25962590    def _del_array_values(self, name=None): 
     
    26302624            Layout after self._draw_model 
    26312625        """ 
    2632         if ON_MAC == True: 
     2626        if ON_MAC is True: 
    26332627            time.sleep(1) 
    26342628 
     
    26522646        """ 
    26532647        flag = True 
    2654         ##For 3 different cases: Data2D, Data1D, and theory 
    2655         if self.model == None: 
     2648        # For 3 different cases: Data2D, Data1D, and theory 
     2649        if self.model is None: 
    26562650            msg = "Please select a model first..." 
    26572651            wx.MessageBox(msg, 'Info') 
     
    26652659            self.qmin_x = data_min 
    26662660            self.qmax_x = math.sqrt(x * x + y * y) 
    2667             #self.data.mask = numpy.ones(len(self.data.data),dtype=bool) 
     2661            # self.data.mask = numpy.ones(len(self.data.data),dtype=bool) 
    26682662            # check smearing 
    26692663            if not self.disable_smearer.GetValue(): 
    2670                 ## set smearing value whether or 
     2664                # set smearing value whether or 
    26712665                # not the data contain the smearing info 
    26722666                if self.pinhole_smearer.GetValue(): 
     
    26752669                    flag = True 
    26762670 
    2677         elif self.data == None: 
     2671        elif self.data is None: 
    26782672            self.qmin_x = _QMIN_DEFAULT 
    26792673            self.qmax_x = _QMAX_DEFAULT 
     
    26862680            # check smearing 
    26872681            if not self.disable_smearer.GetValue(): 
    2688                 ## set smearing value whether or 
     2682                # set smearing value whether or 
    26892683                # not the data contain the smearing info 
    26902684                if self.slit_smearer.GetValue(): 
     
    26972691            flag = False 
    26982692 
    2699         if flag == False: 
     2693        if flag is False: 
    27002694            msg = "Cannot Plot :Must enter a number!!!  " 
    27012695            wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
     
    27142708        self.state.qmax = self.qmax_x 
    27152709 
    2716         #reset the q range values 
     2710        # reset the q range values 
    27172711        self._reset_plotting_range(self.state) 
    27182712        self._draw_model() 
     
    27552749                logging.error(traceback.format_exc()) 
    27562750        # Make sure the resduals plot goes to the last 
    2757         if res_item != None: 
     2751        if res_item is not None: 
    27582752            graphs.append(res_item[0]) 
    27592753            canvases.append(res_item[1]) 
     
    27742768        the # to the browser. 
    27752769 
    2776         :param evt: on Help Button pressed event 
    2777         """ 
    2778  
    2779         if self.model != None: 
     2770        :param event: on Help Button pressed event 
     2771        """ 
     2772 
     2773        if self.model is not None: 
    27802774            name = self.formfactorbox.GetValue() 
    2781             _TreeLocation = 'user/models/'+ name.lower()+'.html' 
     2775            _TreeLocation = 'user/models/' + name.lower()+'.html' 
    27822776            _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, 
    27832777                                              "", name + " Help") 
     
    27862780            _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, 
    27872781                                              "", "General Model Help") 
    2788  
    27892782 
    27902783    def on_model_help_clicked(self, event): 
     
    27982791        give the message that none is available. 
    27992792 
    2800         :param evt: on Description Button pressed event 
    2801         """ 
    2802  
    2803         if self.model == None: 
     2793        :param event: on Description Button pressed event 
     2794        """ 
     2795 
     2796        if self.model is None: 
    28042797            name = 'index.html' 
    28052798        else: 
     
    28082801        msg = 'Model description:\n' 
    28092802        info = "Info" 
    2810         if self.model != None: 
    2811 #                frame.Destroy() 
     2803        if self.model is not None: 
     2804            # frame.Destroy() 
    28122805            if str(self.model.description).rstrip().lstrip() == '': 
    28132806                msg += "Sorry, no information is available for this model." 
     
    28782871            for key in self.model.magnetic_params: 
    28792872                if key.count('M0') > 0: 
    2880                     #reset mag value to zero fo safety 
     2873                    # reset mag value to zero fo safety 
    28812874                    self.model.setParam(key, 0.0) 
    28822875 
    28832876        self.Show(False) 
    28842877        self.set_model_param_sizer(self.model) 
    2885         #self._set_sizer_dispersion() 
     2878        # self._set_sizer_dispersion() 
    28862879        self.state.magnetic_on = self.magnetic_on 
    28872880        self.SetupScrolling() 
     
    28982891        running "file:///...." 
    28992892 
    2900         :param evt: Triggers on clicking ? in polydispersity box 
     2893        :param event: Triggers on clicking ? in polydispersity box 
    29012894        """ 
    29022895 
     
    29362929        content = 'sasview_parameter_values:' 
    29372930        # Do it if params exist 
    2938         if  self.parameters != []: 
     2931        if self.parameters: 
    29392932 
    29402933            # go through the parameters 
     
    29802973 
    29812974        # Do it if params exist 
    2982         if  self.parameters != []: 
     2975        if self.parameters: 
    29832976 
    29842977            for param in self.parameters: 
    2985                 content += param[1] #parameter name 
     2978                content += param[1]  # parameter name 
    29862979                content += tab 
    29872980                content += param[1] + "_err" 
     
    29902983            content += crlf 
    29912984 
    2992             #row of values and errors... 
     2985            # row of values and errors... 
    29932986            for param in self.parameters: 
    2994                 content += param[2].GetValue() #value 
     2987                content += param[2].GetValue()  # value 
    29952988                content += tab 
    2996                 content += param[4].GetValue() #error 
     2989                content += param[4].GetValue()  # error 
    29972990                content += tab 
    29982991 
     
    30002993        else: 
    30012994            return False 
    3002  
    30032995 
    30042996    def get_copy_latex(self): 
     
    30223014 
    30233015        # Do it if params exist 
    3024         if  self.parameters != []: 
     3016        if self.parameters: 
    30253017 
    30263018            content += '{|' 
     
    30313023 
    30323024            for index, param in enumerate(self.parameters): 
    3033                 content += param[1].replace('_', '\_') #parameter name 
     3025                content += param[1].replace('_', '\_')  # parameter name 
    30343026                content += ' & ' 
    30353027                content += param[1].replace('_', '\_') + "\_err" 
     
    30393031            content += crlf 
    30403032 
    3041             #row of values and errors... 
     3033            # row of values and errors... 
    30423034            for index, param in enumerate(self.parameters): 
    3043                 content += param[2].GetValue() #parameter value 
     3035                content += param[2].GetValue()  # parameter value 
    30443036                content += ' & ' 
    3045                 content += param[4].GetValue() #parameter error 
     3037                content += param[4].GetValue()  # parameter error 
    30463038                if index < len(self.parameters) - 1: 
    30473039                    content += ' & ' 
     
    30543046        else: 
    30553047            return False 
    3056  
    30573048 
    30583049    def set_clipboard(self, content=None): 
     
    31013092            # 1D 
    31023093            else: 
    3103                 ## for 1D all parameters except orientation 
     3094                # for 1D all parameters except orientation 
    31043095                if not item[1] in orient_param: 
    31053096                    try: 
     
    31333124            except Exception: 
    31343125                logging.error(traceback.format_exc()) 
    3135             content += name + ',' + str(check) + ',' +\ 
    3136                     value + disfunc + ',' + bound_lo + ',' +\ 
    3137                     bound_hi + ':' 
     3126            content += name + ',' + str(check) + ',' + value + disfunc + ',' + \ 
     3127                       bound_lo + ',' + bound_hi + ':' 
    31383128 
    31393129        return content 
     
    32133203 
    32143204        # Do it if params exist 
    3215         if  self.parameters != []: 
     3205        if self.parameters: 
    32163206            # go through the parameters 
    32173207            self._get_paste_helper(self.parameters, 
     
    32613251                                pd = int(pd) 
    32623252                        except Exception: 
    3263                             #continue 
     3253                            # continue 
    32643254                            if not pd and pd != '': 
    32653255                                continue 
     
    32893279                    else: 
    32903280                        is_true = None 
    3291                     if is_true != None: 
     3281                    if is_true is not None: 
    32923282                        item[0].SetValue(is_true) 
    32933283            # 1D 
    32943284            else: 
    3295                 ## for 1D all parameters except orientation 
     3285                # for 1D all parameters except orientation 
    32963286                if not item[1] in orient_param: 
    32973287                    name = item[1] 
     
    33023292                        pd = value[0] 
    33033293                        if name.count('.') > 0: 
    3304                             # If this is parameter.width, then pd may be a floating 
    3305                             # point value or it may be an array distribution. 
    3306                             # Nothing to do for parameter.npts or parameter.nsigmas. 
     3294                            # If this is parameter.width, then pd may be a 
     3295                            # floating point value or it may be an array 
     3296                            # distribution. Nothing to do for parameter.npts or 
     3297                            # parameter.nsigmas. 
    33073298                            try: 
    33083299                                pd = float(pd) 
     
    33103301                                    pd = int(pd) 
    33113302                            except: 
    3312                                 #continue 
     3303                                # continue 
    33133304                                if not pd and pd != '': 
    33143305                                    continue 
     
    33383329                        else: 
    33393330                            is_true = None 
    3340                         if is_true != None: 
     3331                        if is_true is not None: 
    33413332                            item[0].SetValue(is_true) 
     3333 
     3334        self.select_param(event=None) 
     3335        self.Refresh() 
    33423336 
    33433337    def _paste_poly_help(self, item, value): 
     
    34023396            logging.error(traceback.format_exc()) 
    34033397            print "Error in BasePage._paste_poly_help: %s" % \ 
    3404                                     sys.exc_info()[1] 
     3398                  sys.exc_info()[1] 
    34053399 
    34063400    def _set_disp_cb(self, isarray, item): 
     
    34683462        self.categorybox.Clear() 
    34693463        cat_list = sorted(self.master_category_dict.keys()) 
    3470         if not uncat_str in cat_list: 
     3464        if uncat_str not in cat_list: 
    34713465            cat_list.append(uncat_str) 
    34723466 
     
    34783472            self.categorybox.SetSelection(0) 
    34793473        else: 
    3480             self.categorybox.SetSelection(\ 
     3474            self.categorybox.SetSelection( 
    34813475                self.categorybox.GetSelection()) 
    3482         #self._on_change_cat(None) 
     3476        # self._on_change_cat(None) 
    34833477 
    34843478    def _on_change_cat(self, event): 
     
    34883482        self.model_name = None 
    34893483        category = self.categorybox.GetStringSelection() 
    3490         if category == None: 
     3484        if category is None: 
    34913485            return 
    34923486        self.model_box.Clear() 
     
    34993493        else: 
    35003494            for (model, enabled) in sorted(self.master_category_dict[category], 
    3501                                       key=lambda name: name[0]): 
     3495                                           key=lambda name: name[0]): 
    35023496                if(enabled): 
    35033497                    self.model_box.Append(model) 
     
    35083502        """ 
    35093503        # This should only be called once per fit tab 
    3510         #print "==== Entering _fill_model_sizer" 
    3511         ##Add model function Details button in fitpanel. 
    3512         ##The following 3 lines are for Mac. Let JHC know before modifying... 
     3504        # print "==== Entering _fill_model_sizer" 
     3505        # Add model function Details button in fitpanel. 
     3506        # The following 3 lines are for Mac. Let JHC know before modifying... 
    35133507        title = "Model" 
    35143508        self.formfactorbox = None 
     
    35423536        self._populate_listbox() 
    35433537        wx.EVT_COMBOBOX(self.categorybox, wx.ID_ANY, self._show_combox) 
    3544         #self.shape_rbutton = wx.RadioButton(self, wx.ID_ANY, 'Shapes', 
     3538        # self.shape_rbutton = wx.RadioButton(self, wx.ID_ANY, 'Shapes', 
    35453539        #                                     style=wx.RB_GROUP) 
    3546         #self.shape_indep_rbutton = wx.RadioButton(self, wx.ID_ANY, 
     3540        # self.shape_indep_rbutton = wx.RadioButton(self, wx.ID_ANY, 
    35473541        #                                          "Shape-Independent") 
    3548         #self.struct_rbutton = wx.RadioButton(self, wx.ID_ANY, 
     3542        # self.struct_rbutton = wx.RadioButton(self, wx.ID_ANY, 
    35493543        #                                     "Structure Factor ") 
    3550         #self.plugin_rbutton = wx.RadioButton(self, wx.ID_ANY, 
     3544        # self.plugin_rbutton = wx.RadioButton(self, wx.ID_ANY, 
    35513545        #                                     "Uncategorized") 
    35523546 
    3553         #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
     3547        # self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
    35543548        #                   id=self.shape_rbutton.GetId()) 
    3555         #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
     3549        # self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
    35563550        #                    id=self.shape_indep_rbutton.GetId()) 
    3557         #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
     3551        # self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
    35583552        #                    id=self.struct_rbutton.GetId()) 
    3559         #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
     3553        # self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
    35603554        #                    id=self.plugin_rbutton.GetId()) 
    3561         #MAC needs SetValue 
     3555        # MAC needs SetValue 
    35623556 
    35633557        show_cat_button = wx.Button(self, wx.ID_ANY, "Modify") 
    35643558        cat_tip = "Modify model categories \n" 
    35653559        cat_tip += "(also accessible from the menu bar)." 
    3566         show_cat_button.SetToolTip( wx.ToolTip(cat_tip) ) 
     3560        show_cat_button.SetToolTip(wx.ToolTip(cat_tip)) 
    35673561        show_cat_button.Bind(wx.EVT_BUTTON, self._on_modify_cat) 
    35683562        sizer_cat_box.Add(self.categorybox, 1, wx.RIGHT, 3) 
    3569         sizer_cat_box.Add((10,10)) 
     3563        sizer_cat_box.Add((10, 10)) 
    35703564        sizer_cat_box.Add(show_cat_button) 
    3571         #self.shape_rbutton.SetValue(True) 
     3565        # self.shape_rbutton.SetValue(True) 
    35723566 
    35733567        sizer_radiobutton = wx.GridSizer(2, 2, 5, 5) 
    3574         #sizer_radiobutton.Add(self.shape_rbutton) 
    3575         #sizer_radiobutton.Add(self.shape_indep_rbutton) 
    3576         sizer_radiobutton.Add((5,5)) 
     3568        # sizer_radiobutton.Add(self.shape_rbutton) 
     3569        # sizer_radiobutton.Add(self.shape_indep_rbutton) 
     3570        sizer_radiobutton.Add((5, 5)) 
    35773571        sizer_radiobutton.Add(self.model_view, 1, wx.RIGHT, 5) 
    3578         #sizer_radiobutton.Add(self.plugin_rbutton) 
    3579         #sizer_radiobutton.Add(self.struct_rbutton) 
    3580 #        sizer_radiobutton.Add((5,5)) 
     3572        # sizer_radiobutton.Add(self.plugin_rbutton) 
     3573        # sizer_radiobutton.Add(self.struct_rbutton) 
     3574        # sizer_radiobutton.Add((5,5)) 
    35813575        sizer_radiobutton.Add(self.model_help, 1, wx.RIGHT | wx.LEFT, 5) 
    3582 #        sizer_radiobutton.Add((5,5)) 
     3576        # sizer_radiobutton.Add((5,5)) 
    35833577        sizer_radiobutton.Add(self.model_func, 1, wx.RIGHT, 5) 
    35843578        sizer_cat.Add(sizer_cat_box, 1, wx.LEFT, 2.5) 
     
    35963590        self.formfactorbox = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 
    35973591        self.formfactorbox.SetToolTip(wx.ToolTip("Select a Model")) 
    3598         if self.model != None: 
     3592        if self.model is not None: 
    35993593            self.formfactorbox.SetValue(self.model.name) 
    36003594        self.structurebox = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 
     
    36053599        wx.EVT_COMBOBOX(self.structurebox, wx.ID_ANY, self._on_select_model) 
    36063600        wx.EVT_COMBOBOX(self.multifactorbox, wx.ID_ANY, self._on_select_model) 
    3607         ## check model type to show sizer 
    3608         if self.model != None: 
     3601        # check model type to show sizer 
     3602        if self.model is not None: 
    36093603            print "_set_model_sizer_selection: disabled." 
    3610             #self._set_model_sizer_selection(self.model) 
     3604            # self._set_model_sizer_selection(self.model) 
    36113605 
    36123606        sizer_selection.Add(self.text1) 
     
    37073701        """ 
    37083702 
     3703 
    37093704class ModelTextCtrl(wx.TextCtrl): 
    37103705    """ 
     
    37193714 
    37203715    """ 
    3721     ## Set to True when the mouse is clicked while whole string is selected 
     3716    # Set to True when the mouse is clicked while whole string is selected 
    37223717    full_selection = False 
    3723     ## Call back for EVT_SET_FOCUS events 
     3718    # Call back for EVT_SET_FOCUS events 
    37243719    _on_set_focus_callback = None 
    37253720 
     
    37433738            if set_focus_callback is None else set_focus_callback 
    37443739        self.Bind(wx.EVT_SET_FOCUS, self._on_set_focus) 
    3745         self.Bind(wx.EVT_KILL_FOCUS, self._silent_kill_focus \ 
    3746             if kill_focus_callback is None else kill_focus_callback) 
    3747         self.Bind(wx.EVT_TEXT_ENTER, parent._onparamEnter \ 
    3748             if text_enter_callback is None else text_enter_callback) 
     3740        self.Bind(wx.EVT_KILL_FOCUS, self._silent_kill_focus 
     3741        if kill_focus_callback is None else kill_focus_callback) 
     3742        self.Bind(wx.EVT_TEXT_ENTER, parent._onparamEnter 
     3743        if text_enter_callback is None else text_enter_callback) 
    37493744        if not ON_MAC: 
    3750             self.Bind(wx.EVT_LEFT_UP, self._highlight_text \ 
    3751                 if mouse_up_callback is None else mouse_up_callback) 
     3745            self.Bind(wx.EVT_LEFT_UP, self._highlight_text 
     3746            if mouse_up_callback is None else mouse_up_callback) 
    37523747 
    37533748    def _on_set_focus(self, event): 
     
    37893784 
    37903785        event.Skip() 
    3791         #pass 
     3786        # pass 
  • src/sas/sasgui/perspectives/fitting/fitpage.py

    r55db501 rf668101  
    1414from sasmodels.weights import MODELS as POLYDISPERSITY_MODELS 
    1515 
    16 from sas.sasgui.guiframe.events import StatusEvent 
    17 from sas.sasgui.guiframe.events import NewPlotEvent 
    18 from sas.sasgui.guiframe.events import PlotQrangeEvent 
     16from sas.sasgui.guiframe.events import StatusEvent, NewPlotEvent, \ 
     17    PlotQrangeEvent 
    1918from sas.sasgui.guiframe.dataFitting import check_data_validity 
    20 from sas.sasgui.guiframe.utils import format_number 
    21 from sas.sasgui.guiframe.utils import check_float 
     19from sas.sasgui.guiframe.utils import format_number, check_float 
    2220from sas.sasgui.guiframe.documentation_window import DocumentationWindow 
     21 
     22from sas.sasgui.perspectives.fitting.basepage import BasicPage as BasicPage 
     23from sas.sasgui.perspectives.fitting.basepage import PageInfoEvent as \ 
     24    PageInfoEvent 
     25from sas.sascalc.data_util.qsmearing import smear_selection 
     26from .basepage import ModelTextCtrl 
    2327 
    2428(Chi2UpdateEvent, EVT_CHI2_UPDATE) = wx.lib.newevent.NewEvent() 
     
    2832SMEAR_SIZE_H = 0.00 
    2933 
    30 from sas.sasgui.perspectives.fitting.basepage import BasicPage as BasicPage 
    31 from sas.sasgui.perspectives.fitting.basepage import PageInfoEvent as PageInfoEvent 
    32 from sas.sascalc.data_util.qsmearing import smear_selection 
    33 from .basepage import ModelTextCtrl 
    34  
    3534 
    3635class FitPage(BasicPage): 
     
    4948        BasicPage.__init__(self, parent, color=color) 
    5049 
    51         ## draw sizer 
     50        # draw sizer 
    5251        self._fill_data_sizer() 
    5352        self.is_2D = None 
     
    7271        self.enable_fit_button() 
    7372        self.fill_data_combobox(data_list=self.data_list) 
    74         #create a default data for an empty panel 
     73        # create a default data for an empty panel 
    7574        self.create_default_data() 
    7675        self._manager.frame.Bind(wx.EVT_SET_FOCUS, self.on_set_focus) 
     
    105104        self.data_box_description.SetForegroundColour(dname_color) 
    106105        boxsizer1 = wx.StaticBoxSizer(self.data_box_description, wx.VERTICAL) 
    107         #---------------------------------------------------------- 
     106        # ---------------------------------------------------------- 
    108107        sizer_data = wx.BoxSizer(wx.HORIZONTAL) 
    109108        self.dataSource = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 
     
    134133        self.enable_datasource() 
    135134        if len(data_list) > 0: 
    136             #find the maximum range covering all data 
     135            # find the maximum range covering all data 
    137136            qmin, qmax, npts = self.compute_data_set_range(data_list) 
    138137            self.qmin_data_set = qmin 
     
    186185 
    187186        :return: True or False 
    188  
    189187        """ 
    190188        if self.data.__class__.__name__ == "Data2D" or \ 
     
    200198        buttons, xi^2, number of points etc. 
    201199        """ 
    202         is_2Ddata = False 
     200        is_2d_data = False 
    203201 
    204202        # Check if data is 2D 
    205203        if self.data.__class__.__name__ == "Data2D" or \ 
    206204                        self.enable2D: 
    207             is_2Ddata = True 
     205            is_2d_data = True 
    208206 
    209207        title = "Fitting" 
    210         #smear messages & titles 
     208        # smear messages & titles 
    211209        smear_message_none = "No smearing is selected..." 
    212210        smear_message_dqdata = "The dQ data is being used for smearing..." 
     
    226224        self._get_smear_info() 
    227225 
    228         #Sizers 
     226        # Sizers 
    229227        box_description_range = wx.StaticBox(self, wx.ID_ANY, str(title)) 
    230228        box_description_range.SetForegroundColour(wx.BLUE) 
     
    245243        sizer_weighting = wx.BoxSizer(wx.HORIZONTAL) 
    246244        weighting_box.SetMinSize((_DATA_BOX_WIDTH, 40)) 
    247         #Filling the sizer containing weighting info. 
     245        # Filling the sizer containing weighting info. 
    248246        self.dI_noweight = wx.RadioButton(self, wx.ID_ANY, 
    249247                                          'No Weighting', style=wx.RB_GROUP) 
     
    287285                        self._on_select_accuracy) 
    288286 
    289         #Fit button 
     287        # Fit button 
    290288        self.btFit = wx.Button(self, self._ids.next(), 'Fit') 
    291289        self.default_bt_colour = self.btFit.GetDefaultAttributes() 
     
    293291        self.btFit.SetToolTipString("Start fitting.") 
    294292 
    295         #General Help button 
     293        # General Help button 
    296294        self.btFitHelp = wx.Button(self, wx.ID_ANY, 'Help') 
    297295        self.btFitHelp.SetToolTipString("General fitting help.") 
    298296        self.btFitHelp.Bind(wx.EVT_BUTTON, self._onFitHelp) 
    299297         
    300         #Resolution Smearing Help button (for now use same technique as 
    301         #used for dI help to get tiniest possible button that works 
    302         #both on MAC and PC.  Should completely rewrite the fitting sizer  
    303         #in future.  This is minimum to get out release 3.1 
     298        # Resolution Smearing Help button (for now use same technique as 
     299        # used for dI help to get tiniest possible button that works 
     300        # both on MAC and PC.  Should completely rewrite the fitting sizer 
     301        # in future.  This is minimum to get out release 3.1 
    304302        #        comment June 14, 2015     --- PDB 
    305303        if sys.platform.count("win32") > 0: 
    306             size_q = (20, 15)  #on PC 
     304            size_q = (20, 15)  # on PC 
    307305        else: 
    308             size_q = (30, 20)  #on MAC 
     306            size_q = (30, 20)  # on MAC 
    309307        self.btSmearHelp = wx.Button(self, wx.ID_ANY, '?', 
    310308                                     style=wx.BU_EXACTFIT, size=size_q) 
     
    312310        self.btSmearHelp.Bind(wx.EVT_BUTTON, self._onSmearHelp) 
    313311         
    314         #textcntrl for custom resolution 
     312        # textcntrl for custom resolution 
    315313        self.smear_pinhole_max = ModelTextCtrl(self, wx.ID_ANY, 
    316314                            size=(_BOX_WIDTH - 25, 20), 
     
    330328                            text_enter_callback=self.onSlitSmear) 
    331329 
    332         ## smear 
     330        # smear 
    333331        self.smear_data_left = BGTextCtrl(self, wx.ID_ANY, 
    334332                                          size=(_BOX_WIDTH - 25, 20), style=0) 
     
    338336        self.smear_data_right.SetValue(str(self.dq_r)) 
    339337 
    340         #set default values for smear 
     338        # set default values for smear 
    341339        self.smear_pinhole_max.SetValue(str(self.dx_max)) 
    342340        self.smear_pinhole_min.SetValue(str(self.dx_min)) 
     
    344342        self.smear_slit_width.SetValue(str(self.dxw)) 
    345343 
    346         #Filling the sizer containing instruments smearing info. 
     344        # Filling the sizer containing instruments smearing info. 
    347345        self.disable_smearer = wx.RadioButton(self, wx.ID_ANY, 
    348346                                              'None', style=wx.RB_GROUP) 
    349347        self.enable_smearer = wx.RadioButton(self, wx.ID_ANY, 'Use dQ Data') 
    350         #self.enable_smearer.SetToolTipString( 
    351         #"Click to use the loaded dQ data for smearing.") 
     348        # self.enable_smearer.SetToolTipString( 
     349        # "Click to use the loaded dQ data for smearing.") 
    352350        self.pinhole_smearer = wx.RadioButton(self, wx.ID_ANY, 
    353351                                              'Custom Pinhole Smear') 
    354         #self.pinhole_smearer.SetToolTipString 
    355         #("Click to input custom resolution for pinhole smearing.") 
     352        # self.pinhole_smearer.SetToolTipString 
     353        # ("Click to input custom resolution for pinhole smearing.") 
    356354        self.slit_smearer = wx.RadioButton(self, wx.ID_ANY, 'Custom Slit Smear') 
    357         #self.slit_smearer.SetToolTipString 
    358         #("Click to input custom resolution for slit smearing.") 
     355        # self.slit_smearer.SetToolTipString 
     356        # ("Click to input custom resolution for slit smearing.") 
    359357        self.Bind(wx.EVT_RADIOBUTTON, self.onSmear, 
    360358                  id=self.disable_smearer.GetId()) 
     
    379377        self.Npts_fit = BGTextCtrl(self, wx.ID_ANY, "-", size=(75, 20), style=0) 
    380378        self.Npts_fit.SetToolTipString( 
    381                             " Npts : number of points selected for fitting") 
     379            " Npts : number of points selected for fitting") 
    382380        self.Npts_total = ModelTextCtrl(self, wx.ID_ANY, size=(_BOX_WIDTH, 20), 
    383                             style=wx.TE_PROCESS_ENTER, 
    384                             text_enter_callback=self._onQrangeEnter) 
     381                                        style=wx.TE_PROCESS_ENTER, 
     382                                        text_enter_callback=self._onQrangeEnter) 
    385383        self.Npts_total.SetValue(format_number(self.npts_x)) 
    386         self.Npts_total.SetToolTipString(\ 
    387                                 " Total Npts : total number of data points") 
     384        self.Npts_total.SetToolTipString( 
     385            " Total Npts : total number of data points") 
    388386 
    389387        # Update and Draw button 
     
    430428        self.smear_description_2d_y = wx.StaticText(self, wx.ID_ANY, 
    431429                            smear_message_2d_y_title, style=wx.ALIGN_LEFT) 
    432         self.smear_description_2d_y.SetToolTipString(\ 
     430        self.smear_description_2d_y.SetToolTipString( 
    433431                                    " dQs(perpendicular) in q_phi direction.") 
    434432        self.smear_description_pin_min = wx.StaticText(self, wx.ID_ANY, 
     
    441439                        smear_message_slit_width_title, style=wx.ALIGN_LEFT) 
    442440 
    443         #arrange sizers 
     441        # arrange sizers 
    444442        self.sizer_set_smearer.Add(sizer_smearer) 
    445443        self.sizer_set_smearer.Add((10, 10)) 
    446444        self.sizer_set_smearer.Add(self.smear_description_none, 
    447                                     0, wx.CENTER, 10) 
     445                                   0, wx.CENTER, 10) 
    448446        self.sizer_set_smearer.Add(self.smear_description_dqdata, 
    449                                     0, wx.CENTER, 10) 
     447                                   0, wx.CENTER, 10) 
    450448        self.sizer_set_smearer.Add(self.smear_description_2d, 
    451                                     0, wx.CENTER, 10) 
     449                                   0, wx.CENTER, 10) 
    452450        self.sizer_new_smear.Add(self.smear_description_type, 
    453                                   0, wx.CENTER, 10) 
     451                                 0, wx.CENTER, 10) 
    454452        self.sizer_new_smear.Add(self.smear_description_accuracy_type, 
    455                                   0, wx.CENTER, 10) 
     453                                 0, wx.CENTER, 10) 
    456454        self.sizer_new_smear.Add(self.smear_accuracy) 
    457455        self.sizer_new_smear.Add(self.smear_description_smear_type, 
    458                                   0, wx.CENTER, 10) 
     456                                 0, wx.CENTER, 10) 
    459457        self.sizer_new_smear.Add((15, -1)) 
    460         self.sizer_new_smear.Add(self.smear_description_2d_x, 
    461                                   0, wx.CENTER, 10) 
     458        self.sizer_new_smear.Add(self.smear_description_2d_x, 0, wx.CENTER, 10) 
    462459        self.sizer_new_smear.Add(self.smear_description_pin_min, 
    463                                   0, wx.CENTER, 10) 
     460                                 0, wx.CENTER, 10) 
    464461        self.sizer_new_smear.Add(self.smear_description_slit_height, 
    465                                   0, wx.CENTER, 10) 
    466  
    467         self.sizer_new_smear.Add(self.smear_pinhole_min, 
    468                                   0, wx.CENTER, 10) 
    469         self.sizer_new_smear.Add(self.smear_slit_height, 
    470                                   0, wx.CENTER, 10) 
    471         self.sizer_new_smear.Add(self.smear_data_left, 
    472                                   0, wx.CENTER, 10) 
     462                                 0, wx.CENTER, 10) 
     463 
     464        self.sizer_new_smear.Add(self.smear_pinhole_min, 0, wx.CENTER, 10) 
     465        self.sizer_new_smear.Add(self.smear_slit_height, 0, wx.CENTER, 10) 
     466        self.sizer_new_smear.Add(self.smear_data_left, 0, wx.CENTER, 10) 
    473467        self.sizer_new_smear.Add((20, -1)) 
    474468        self.sizer_new_smear.Add(self.smear_description_2d_y, 
    475                                   0, wx.CENTER, 10) 
     469                                 0, wx.CENTER, 10) 
    476470        self.sizer_new_smear.Add(self.smear_description_pin_max, 
    477                                   0, wx.CENTER, 10) 
     471                                 0, wx.CENTER, 10) 
    478472        self.sizer_new_smear.Add(self.smear_description_slit_width, 
    479                                   0, wx.CENTER, 10) 
     473                                 0, wx.CENTER, 10) 
    480474 
    481475        self.sizer_new_smear.Add(self.smear_pinhole_max, 0, wx.CENTER, 10) 
     
    502496 
    503497        # Show only the relevant smear messages, etc 
    504         if self.current_smearer == None: 
    505             if not is_2Ddata: 
     498        if self.current_smearer is None: 
     499            if not is_2d_data: 
    506500                self.smear_description_none.Show(True) 
    507501                self.enable_smearer.Disable() 
     
    509503                self.smear_description_none.Show(True) 
    510504                self.slit_smearer.Disable() 
    511             if self.data == None: 
     505            if self.data is None: 
    512506                self.slit_smearer.Disable() 
    513507                self.pinhole_smearer.Disable() 
     
    516510            self._show_smear_sizer() 
    517511        boxsizer_range.Add(self.sizer_set_masking) 
    518         #2D data? default 
    519         is_2Ddata = False 
    520  
    521         #check if it is 2D data 
     512        # 2D data? default 
     513        is_2d_data = False 
     514 
     515        # check if it is 2D data 
    522516        if self.data.__class__.__name__ == "Data2D" or self.enable2D: 
    523             is_2Ddata = True 
     517            is_2d_data = True 
    524518 
    525519        self.sizer5.Clear(True) 
     
    569563        sizer.Add(wx.StaticText(self, wx.ID_ANY, ' Max[1/A]')) 
    570564        sizer.Add(self.EditMask_title) 
    571         sizer.Add((-1,5)) 
     565        sizer.Add((-1, 5)) 
    572566 
    573567        sizer.Add(self.reset_qrange) 
     
    575569        sizer.Add(self.qmax) 
    576570        sizer.Add(self.btEditMask) 
    577         sizer.Add((-1,5)) 
    578  
    579         sizer.AddMany(5*[(-1,5)]) 
     571        sizer.Add((-1, 5)) 
     572 
     573        sizer.AddMany(5*[(-1, 5)]) 
    580574 
    581575        sizer.Add(box_description_1, 0, 0) 
     
    583577        sizer.Add(self.points_sizer, 0, 0) 
    584578        sizer.Add(self.draw_button, 0, 0) 
    585         sizer.Add((-1,5)) 
     579        sizer.Add((-1, 5)) 
    586580         
    587581        sizer.Add(self.tcChi, 0, 0) 
     
    593587        boxsizer_range.Add(sizer_chi2) 
    594588        boxsizer_range.Add(sizer) 
    595         if is_2Ddata: 
     589        if is_2d_data: 
    596590            self.btEditMask.Enable() 
    597591            self.EditMask_title.Enable() 
     
    599593            self.btEditMask.Disable() 
    600594            self.EditMask_title.Disable() 
    601         ## save state 
     595        # save state 
    602596        self.save_current_state() 
    603597        self.sizer5.Add(boxsizer_range, 0, wx.EXPAND | wx.ALL, 10) 
    604598        self.sizer5.Layout() 
    605599 
    606  
    607600    def _set_sizer_dispersion(self): 
    608601        """ 
     
    614607 
    615608        self.sizer4_4.Clear(True) 
    616         if self.model == None: 
    617             ##no model is selected 
     609        if self.model is None: 
     610            # no model is selected 
    618611            return 
    619612        if not self.enable_disp.GetValue(): 
    620             ## the user didn't select dispersity display 
     613            # the user didn't select dispersity display 
    621614            return 
    622615 
    623616        self._reset_dispersity() 
    624617 
    625         ## fill a sizer with the combobox to select dispersion type 
     618        # fill a sizer with the combobox to select dispersion type 
    626619        model_disp = wx.StaticText(self, wx.ID_ANY, 'Function') 
    627620        CHECK_STATE = self.cb1.GetValue() 
     
    646639            err_text = '' 
    647640        self.text_disp_1 = wx.StaticText(self, wx.ID_ANY, err_text) 
    648         self.sizer4_4.Add(self.text_disp_1, (iy, ix), (1, 1), \ 
     641        self.sizer4_4.Add(self.text_disp_1, (iy, ix), (1, 1), 
    649642                          wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    650643 
    651644        ix += 1 
    652645        self.text_disp_min = wx.StaticText(self, wx.ID_ANY, 'Min') 
    653         self.sizer4_4.Add(self.text_disp_min, (iy, ix), (1, 1), \ 
     646        self.sizer4_4.Add(self.text_disp_min, (iy, ix), (1, 1), 
    654647                            wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    655648 
     
    684677                if item in self.model.magnetic_params: 
    685678                    continue 
    686             if not item in self.model.orientation_params: 
    687                 if not item in self.disp_cb_dict: 
     679            if item not in self.model.orientation_params: 
     680                if item not in self.disp_cb_dict: 
    688681                    self.disp_cb_dict[item] = None 
    689682                name0 = "Distribution of " + item 
     
    691684                name2 = item + ".npts" 
    692685                name3 = item + ".nsigmas" 
    693                 if not name1 in self.model.details: 
     686                if name1 not in self.model.details: 
    694687                    self.model.details[name1] = ["", None, None] 
    695688 
     
    717710                        ctl1.SetValue(str(format_number(value, True))) 
    718711                        self.sizer4_4.Add(ctl1, (iy, ix), (1, 1), wx.EXPAND) 
    719                         ## text to show error sign 
     712                        # text to show error sign 
    720713                        ix = 2 
    721714                        text2 = wx.StaticText(self, wx.ID_ANY, '+/-') 
     
    777770                        Tct2.SetValue(str(format_number(value))) 
    778771                        self.sizer4_4.Add(Tct2, (iy, ix), (1, 1), 
    779                                            wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
     772                                          wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    780773                        self.fixed_param.append([None, name3, Tct2, 
    781774                                                 None, None, None, 
     
    803796                if item in self.model.magnetic_params: 
    804797                    continue 
    805             if  item in self.model.orientation_params: 
    806                 if not item in self.disp_cb_dict: 
     798            if item in self.model.orientation_params: 
     799                if item not in self.disp_cb_dict: 
    807800                    self.disp_cb_dict[item] = None 
    808801                name0 = "Distribution of " + item 
     
    811804                name3 = item + ".nsigmas" 
    812805 
    813                 if not name1 in self.model.details: 
     806                if name1 not in self.model.details: 
    814807                    self.model.details[name1] = ["", None, None] 
    815808 
     
    856849 
    857850                        self.sizer4_4.Add(ctl1, (iy, ix), (1, 1), wx.EXPAND) 
    858                         ## text to show error sign 
     851                        # text to show error sign 
    859852                        ix = 2 
    860853                        text2 = wx.StaticText(self, wx.ID_ANY, '+/-') 
     
    969962 
    970963        self.state.model = self.model.clone() 
    971         ## save state into 
    972         self.state.cb1 = self.cb1.GetValue() 
     964 
     965        # save state into 
    973966        self._copy_parameters_state(self.parameters, self.state.parameters) 
    974967        self._copy_parameters_state(self.orientation_params_disp, 
     
    980973        wx.PostEvent(self.parent, 
    981974                     StatusEvent(status=" Selected Distribution: Gaussian")) 
    982         #Fill the list of fittable parameters 
    983         #self.select_all_param(event=None) 
     975 
     976        # Fill the list of fittable parameters 
    984977        self.get_all_checked_params() 
    985978        self.Layout() 
     
    989982        Update and Draw the model 
    990983        """ 
    991         if self.model == None: 
     984        if self.model is None: 
    992985            msg = "Please select a Model first..." 
    993986            wx.MessageBox(msg, 'Info') 
     
    999992            self.create_default_data() 
    1000993        """ 
    1001         flag,is_modified = self._update_paramv_on_fit() 
    1002  
    1003         wx.CallAfter(self._onparamEnter_helper,is_modified) 
     994        flag, is_modified = self._update_paramv_on_fit() 
     995 
     996        wx.CallAfter(self._onparamEnter_helper, is_modified) 
    1004997        if not flag: 
    1005998            msg = "The parameters are invalid" 
     
    10111004        Allow to fit 
    10121005        """ 
    1013         if event != None: 
     1006        if event is not None: 
    10141007            event.Skip() 
    10151008        if self.fit_started: 
     
    10511044            return 
    10521045 
    1053         self.select_param(event=None) 
     1046        self.select_param() 
    10541047 
    10551048        # Remove or do not allow fitting on the Q=0 point, especially 
     
    10621055                                    qmax=self.qmax_x) 
    10631056 
    1064         #single fit 
    1065         #self._manager.onFit(uid=self.uid) 
     1057        # single fit 
     1058        # self._manager.onFit(uid=self.uid) 
    10661059        self.fit_started = self._manager.onFit(uid=self.uid) 
    10671060        wx.CallAfter(self.set_fitbutton) 
     
    10761069        versions of Wx (before 2.9) and thus not the release version of 
    10771070        installers, the help comes up at the top level of the file as 
    1078         webbrowser does not pass anything past the # to the browser when it is 
     1071        web browser does not pass anything past the # to the browser when it is 
    10791072        running "file:///...." 
    10801073 
    1081     :param evt: Triggers on clicking the help button 
    1082     """ 
     1074        :param evt: Triggers on clicking the help button 
     1075        """ 
    10831076 
    10841077        _TreeLocation = "user/sasgui/perspectives/fitting/fitting_help.html" 
     
    10951088        versions of Wx (before 2.9) and thus not the release version of 
    10961089        installers, the help comes up at the top level of the file as 
    1097         webbrowser does not pass anything past the # to the browser when it is 
     1090        web browser does not pass anything past the # to the browser when it is 
    10981091        running "file:///...." 
    10991092 
    1100     :param evt: Triggers on clicking the help button 
    1101     """ 
     1093        :param evt: Triggers on clicking the help button 
     1094        """ 
    11021095 
    11031096        _TreeLocation = "user/sasgui/perspectives/fitting/sm_help.html" 
     
    11111104        """ 
    11121105        # Skip this feature if we are not on Windows 
    1113         #NOTE: the is_mac data member actually means "is no Windows". 
     1106        # NOTE: the is_mac data member actually means "is no Windows". 
    11141107        if self.is_mac: 
    11151108            return 
     
    11211114            label = "Fit" 
    11221115            color = "black" 
    1123         #self.btFit.Enable(False) 
     1116        # self.btFit.Enable(False) 
    11241117        self.btFit.SetLabel(label) 
    11251118        self.btFit.SetForegroundColour(color) 
     
    11521145        Stop fit 
    11531146        """ 
    1154         if event != None: 
     1147        if event is not None: 
    11551148            event.Skip() 
    11561149        self._manager.stop_fit(self.uid) 
     
    11721165        copy_flag = False 
    11731166        is_poly_enabled = None 
    1174         if event != None: 
    1175             if (event.GetEventObject() == self.formfactorbox\ 
     1167        if event is not None: 
     1168            if (event.GetEventObject() == self.formfactorbox 
    11761169                        and self.structurebox.GetLabel() != 'None')\ 
    11771170                        or event.GetEventObject() == self.structurebox\ 
     
    11861179            self._keep.Enable(False) 
    11871180            self._set_save_flag(False) 
    1188         # TODO: why do we have to variables for one flag?? 
    11891181        self.enable_disp.SetValue(False) 
    11901182        self.disable_disp.SetValue(True) 
     
    12161208                    self._keep.Enable(not self.batch_on) 
    12171209                    self._set_save_flag(True) 
     1210                    self._set_smear(self.data) 
    12181211 
    12191212            # more disables for 2D 
     
    12291222            except: 
    12301223                raise 
    1231                 ## error occured on chisqr computation 
    1232                 #pass 
    1233             ## event to post model to fit to fitting plugins 
     1224                # error occured on chisqr computation 
     1225                # pass 
     1226            # event to post model to fit to fitting plugins 
    12341227            (ModelEventbox, EVT_MODEL_BOX) = wx.lib.newevent.NewEvent() 
    12351228 
    1236             ## set smearing value whether or not 
    1237             #    the data contain the smearing info 
     1229            # set smearing value whether or not data contain the smearing info 
    12381230            evt = ModelEventbox(model=self.model, 
    12391231                            smearer=temp_smear, 
     
    12451237 
    12461238            self._manager._on_model_panel(evt=evt) 
    1247             self.mbox_description.SetLabel("Model [ %s ]" % str(self.model.name)) 
     1239            self.mbox_description.SetLabel("Model [ %s ]" % 
     1240                                           str(self.model.name)) 
    12481241            self.mbox_description.SetForegroundColour(wx.BLUE) 
    12491242            self.state.model = self.model.clone() 
    12501243            self.state.model.name = self.model.name 
    12511244 
    1252         if event != None: 
    1253             ## post state to fit panel 
     1245        if event is not None: 
     1246            # post state to fit panel 
    12541247            new_event = PageInfoEvent(page=self) 
    12551248            wx.PostEvent(self.parent, new_event) 
    1256             #update list of plugins if new plugin is available 
     1249            # update list of plugins if new plugin is available 
    12571250            custom_model = 'Customized Models' 
    12581251            mod_cat = self.categorybox.GetStringSelection() 
     
    12671260                    self.formfactorbox.SetValue(current_val) 
    12681261            # when select a model only from guictr/button 
    1269             if is_poly_enabled != None: 
     1262            if is_poly_enabled is not None: 
    12701263                self.enable_disp.SetValue(is_poly_enabled) 
    12711264                self.disable_disp.SetValue(not is_poly_enabled) 
     
    12951288        when enter value on panel redraw model according to changed 
    12961289        """ 
    1297         if self.model == None: 
     1290        if self.model is None: 
    12981291            msg = "Please select a Model first..." 
    12991292            wx.MessageBox(msg, 'Info') 
    13001293            return 
    13011294 
    1302         #default flag 
     1295        # default flag 
    13031296        flag = False 
    13041297        self.fitrange = True 
    1305         #get event object 
     1298        # get event object 
    13061299        tcrtl = event.GetEventObject() 
    1307         #Clear msg if previously shown. 
     1300        # Clear msg if previously shown. 
    13081301        msg = "" 
    13091302        wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
     
    13161309                if not self.disable_smearer.GetValue(): 
    13171310                    temp_smearer = self.current_smearer 
    1318                     ## set smearing value whether or not 
    1319                     #        the data contain the smearing info 
     1311                    # set smearing value whether or not data contain the 
     1312                    # smearing info 
    13201313                    if self.slit_smearer.GetValue(): 
    13211314                        flag1 = self.update_slit_smear() 
     
    13341327                                              enable_smearer=enable_smearer) 
    13351328                if flag: 
    1336                     #self.compute_chisqr(smearer= temp_smearer) 
    1337  
    1338                     ## new state posted 
     1329                    # self.compute_chisqr(smearer= temp_smearer) 
     1330 
     1331                    # new state posted 
    13391332                    if self.state_change: 
    1340                         #self._undo.Enable(True) 
     1333                        # self._undo.Enable(True) 
    13411334                        event = PageInfoEvent(page=self) 
    13421335                        wx.PostEvent(self.parent, event) 
     
    13481341        else: 
    13491342            self.save_current_state() 
    1350             msg = "Cannot Plot :Must enter a number!!!  " 
     1343            msg = "Cannot Plot: Must enter a number!!!  " 
    13511344            wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
    13521345 
     
    13591352        """ 
    13601353        tcrtl = event.GetEventObject() 
    1361         #Clear msg if previously shown. 
     1354        # Clear msg if previously shown. 
    13621355        msg = "" 
    13631356        wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
     
    13771370            tcrtl.SetBackgroundColour(wx.WHITE) 
    13781371 
    1379         #self._undo.Enable(True) 
     1372        # self._undo.Enable(True) 
    13801373        self.save_current_state() 
    13811374        event = PageInfoEvent(page=self) 
     
    13871380        ON Qrange focus 
    13881381        """ 
    1389         if event != None: 
     1382        if event is not None: 
    13901383            event.Skip() 
    1391         #tcrtl = event.GetEventObject() 
     1384        # tcrtl = event.GetEventObject() 
    13921385        self._validate_qrange(self.qmin, self.qmax) 
    13931386 
     
    13961389        On Qrange textctrl click, make the qrange lines in the plot 
    13971390        """ 
    1398         if event != None: 
     1391        if event is not None: 
    13991392            event.Skip() 
    14001393        if self.data.__class__.__name__ == "Data2D": 
     
    14141407        #On q range value updated. DO not combine with qrange_click(). 
    14151408        """ 
    1416         if event != None: 
     1409        if event is not None: 
    14171410            event.Skip() 
    14181411        if self.data.__class__.__name__ == "Data2D": 
     
    14421435        length = len(self.data.x) 
    14431436        indx = (numpy.abs(self.data.x - x_data)).argmin() 
    1444         #return array.flat[idx] 
     1437        # return array.flat[idx] 
    14451438        if key == wx.WXK_PAGEUP or key == wx.WXK_NUMPAD_PAGEUP: 
    14461439            indx += 1 
     
    14611454        """ 
    14621455        tcrtl = event.GetEventObject() 
    1463         #Clear msg if previously shown. 
     1456        # Clear msg if previously shown. 
    14641457        msg = "" 
    14651458        wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
     
    14911484                wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
    14921485                return 
    1493             #Check if # of points for theory model are valid(>0). 
     1486            # Check if # of points for theory model are valid(>0). 
    14941487            # check for 2d 
    14951488            if self.data.__class__.__name__ == "Data2D" or \ 
     
    14981491                radius = numpy.sqrt(self.data.qx_data * self.data.qx_data + 
    14991492                                    self.data.qy_data * self.data.qy_data) 
    1500                 index_data = ((self.qmin_x <= radius) & \ 
    1501                                 (radius <= self.qmax_x)) 
     1493                index_data = ((self.qmin_x <= radius) & (radius <= self.qmax_x)) 
    15021494                index_data = (index_data) & (self.data.mask) 
    15031495                index_data = (index_data) & (numpy.isfinite(self.data.data)) 
     
    15091501                    return 
    15101502                else: 
    1511                     #self.data.mask = index_data 
    1512                     #self.Npts_fit.SetValue(str(len(self.data.mask))) 
     1503                    # self.data.mask = index_data 
     1504                    # self.Npts_fit.SetValue(str(len(self.data.mask))) 
    15131505                    self.show_npts2fit() 
    15141506            else: 
    1515                 index_data = ((self.qmin_x <= self.data.x) & \ 
     1507                index_data = ((self.qmin_x <= self.data.x) & 
    15161508                              (self.data.x <= self.qmax_x)) 
    15171509                self.Npts_fit.SetValue(str(len(self.data.x[index_data]))) 
     
    15461538            for item in self.parameters: 
    15471539                if item[0].IsShown(): 
    1548                     #Skip the angle parameters if 1D data 
     1540                    # Skip the angle parameters if 1D data 
    15491541                    if self.data.__class__.__name__ != "Data2D" and \ 
    15501542                            not self.enable2D: 
     
    15531545                    if item in self.param_toFit: 
    15541546                        continue 
    1555                     ## hide statictext +/- 
     1547                    # hide statictext +/- 
    15561548                    if len(item) < 4: 
    15571549                        continue 
    1558                     if item[3] != None and item[3].IsShown(): 
     1550                    if item[3] is not None and item[3].IsShown(): 
    15591551                        item[3].Hide() 
    1560                     ## hide textcrtl  for error after fit 
    1561                     if item[4] != None and item[4].IsShown(): 
     1552                    # hide textcrtl  for error after fit 
     1553                    if item[4] is not None and item[4].IsShown(): 
    15621554                        item[4].Hide() 
    15631555 
     
    15651557            for item in self.fittable_param: 
    15661558                if item[0].IsShown(): 
    1567                     #Skip the angle parameters if 1D data 
     1559                    # Skip the angle parameters if 1D data 
    15681560                    if self.data.__class__.__name__ != "Data2D" and \ 
    15691561                            not self.enable2D: 
     
    15741566                    if len(item) < 4: 
    15751567                        continue 
    1576                     ## hide statictext +/- 
    1577                     if item[3] != None and item[3].IsShown(): 
     1568                    # hide statictext +/- 
     1569                    if item[3] is not None and item[3].IsShown(): 
    15781570                        item[3].Hide() 
    1579                     ## hide textcrtl  for error after fit 
    1580                     if item[4] != None and item[4].IsShown(): 
     1571                    # hide textcrtl  for error after fit 
     1572                    if item[4] is not None and item[4].IsShown(): 
    15811573                        item[4].Hide() 
    15821574        return 
     
    15871579        """ 
    15881580        # get the default values 
    1589         if self.dxl == None: 
     1581        if self.dxl is None: 
    15901582            self.dxl = 0.0 
    1591         if self.dxw == None: 
     1583        if self.dxw is None: 
    15921584            self.dxw = "" 
    1593         if self.dx_min == None: 
     1585        if self.dx_min is None: 
    15941586            self.dx_min = SMEAR_SIZE_L 
    1595         if self.dx_max == None: 
     1587        if self.dx_max is None: 
    15961588            self.dx_max = SMEAR_SIZE_H 
    15971589 
     
    16141606        elif self.data.__class__.__name__ == "Data2D" or \ 
    16151607            self.enable2D: 
    1616             if data.dqx_data == None or  data.dqy_data == None: 
     1608            if data.dqx_data is None or data.dqy_data is None: 
    16171609                return 
    1618             elif self.current_smearer != None \ 
     1610            elif self.current_smearer is not None \ 
    16191611                and data.dqx_data.any() != 0 \ 
    16201612                and data.dqx_data.any() != 0: 
     
    16261618                return 
    16271619        # check if it is pinhole smear and get min max if it is. 
    1628         if data.dx != None and all(data.dx != 0): 
     1620        if data.dx is not None and not numpy.any(data.dx): 
    16291621            self.smear_type = "Pinhole" 
    16301622            self.dq_l = data.dx[0] 
     
    16321624 
    16331625        # check if it is slit smear and get min max if it is. 
    1634         elif data.dxl != None or data.dxw != None: 
     1626        elif data.dxl is not None or data.dxw is not None: 
    16351627            self.smear_type = "Slit" 
    1636             if data.dxl != None and all(data.dxl != 0): 
     1628            if data.dxl is not None and not numpy.all(data.dxl, 0): 
    16371629                self.dq_l = data.dxl[0] 
    1638             if data.dxw != None and all(data.dxw != 0): 
     1630            if data.dxw is not None and not numpy.all(data.dxw, 0): 
    16391631                self.dq_r = data.dxw[0] 
    1640         #return self.smear_type,self.dq_l,self.dq_r 
     1632        # return self.smear_type,self.dq_l,self.dq_r 
    16411633 
    16421634    def _show_smear_sizer(self): 
     
    16621654 
    16631655            self.smear_description_dqdata.Show(True) 
    1664             if self.smear_type != None: 
     1656            if self.smear_type is not None: 
    16651657                self.smear_description_smear_type.Show(True) 
    16661658                if self.smear_type == 'Slit': 
     
    17531745        Select an accuracy in 2D custom smear: Xhigh, High, Med, or Low 
    17541746        """ 
    1755         #event.Skip() 
     1747        # event.Skip() 
    17561748        # Check if the accuracy is same as before 
    1757         #self.smear2d_accuracy = event.GetEventObject().GetValue() 
     1749        # self.smear2d_accuracy = event.GetEventObject().GetValue() 
    17581750        self.smear2d_accuracy = self.smear_accuracy.GetValue() 
    17591751        if self.pinhole_smearer.GetValue(): 
     
    17611753        else: 
    17621754            self.onSmear(event=None) 
    1763             if self.current_smearer != None: 
     1755            if self.current_smearer is not None: 
    17641756                self.current_smearer.set_accuracy(accuracy=\ 
    17651757                                                  self.smear2d_accuracy) 
     
    17931785        Build a panel to allow to edit Mask 
    17941786        """ 
    1795         from sas.sasgui.guiframe.local_perspectives.plotting.masking \ 
    1796         import MaskPanel as MaskDialog 
     1787        from sas.sasgui.guiframe.local_perspectives.plotting.masking import \ 
     1788            MaskPanel as MaskDialog 
    17971789 
    17981790        self.panel = MaskDialog(base=self, data=self.data, id=wx.NewId()) 
     
    18051797        is_valid_qrange = self._update_paramv_on_fit() 
    18061798 
    1807         if is_valid_qrange and self.model != None: 
     1799        if is_valid_qrange and self.model is not None: 
    18081800            self.panel.MakeModal(False) 
    18091801            event.Skip() 
     
    18111803            self._draw_model() 
    18121804            self.show_npts2fit() 
    1813         elif self.model == None: 
     1805        elif self.model is None: 
    18141806            self.panel.MakeModal(False) 
    18151807            event.Skip() 
     
    18781870                    npts = len(data.x) 
    18791871                except: 
    1880                     msg = "Unable to find min/max/length of \n data named %s" % \ 
     1872                    msg = "Unable to find min/max/length of \n data named %s" %\ 
    18811873                                data.filename 
    18821874                    wx.PostEvent(self._manager.parent, StatusEvent(status=msg, 
     
    18951887                                               info="error")) 
    18961888                    raise ValueError, msg 
    1897                 ## Maximum value of data 
     1889                # Maximum value of data 
    18981890                qmax = math.sqrt(x * x + y * y) 
    18991891                npts = len(data.data) 
     
    19071899        flag = False 
    19081900        is_data = False 
     1901        npts = 0 
    19091902        try: 
    19101903            old_id = self.data.id 
     
    19181911                flag = True 
    19191912        if data is not None: 
    1920             id = data.id 
    19211913            if is_data: 
    19221914                self.graph_id = self.data.group_id 
     
    19331925            self._set_save_flag(False) 
    19341926        else: 
    1935             if self.model != None: 
     1927            if self.model is not None: 
    19361928                self._set_bookmark_flag(not self.batch_on) 
    19371929                self._keep.Enable(not self.batch_on) 
     
    19401932                self._set_preview_flag(True) 
    19411933 
    1942             self._set_smear(data) 
    19431934            # more disables for 2D 
    19441935            if self.data.__class__.__name__ == "Data2D" or \ 
     
    19471938                self.pinhole_smearer.Enable(True) 
    19481939                self.default_mask = copy.deepcopy(self.data.mask) 
    1949                 if self.data.err_data == None or\ 
    1950                         (self.data.err_data == 1).all() or\ 
    1951                         (self.data.err_data == 0).all(): 
     1940                if self.data.err_data is None or\ 
     1941                        numpy.all(err == 1 for err in self.data.err_data) or \ 
     1942                        not numpy.any(self.data.err_data): 
    19521943                    self.dI_didata.Enable(False) 
    19531944                    self.dI_noweight.SetValue(True) 
     
    19601951                self.slit_smearer.Enable(True) 
    19611952                self.pinhole_smearer.Enable(True) 
    1962                 if self.data.dy == None or\ 
    1963                      (self.data.dy == 1).all() or\ 
    1964                      (self.data.dy == 0).all(): 
     1953 
     1954                if self.data.dy is None or\ 
     1955                     numpy.all(self.data.dy == 1) or\ 
     1956                     not numpy.any(self.data.dy): 
    19651957                    self.dI_didata.Enable(False) 
    19661958                    self.dI_noweight.SetValue(True) 
     
    19701962                    self.dI_didata.SetValue(True) 
    19711963                    self.weightbt_string = self.dI_didata.GetLabelText() 
    1972             # Enable weighting radio uttons 
     1964            # Enable weighting radio buttons 
    19731965            self.dI_noweight.Enable(True) 
    19741966            self.dI_sqrdata.Enable(True) 
     
    19791971            data_name = self.data.name 
    19801972            _, _, npts = self.compute_data_range(self.data) 
    1981             #set maximum range for x in linear scale 
     1973            # set maximum range for x in linear scale 
    19821974            if not hasattr(self.data, "data"):  # Display only for 1D data fit 
    19831975                self.btEditMask.Disable() 
     
    19881980 
    19891981        self.Npts_total.SetValue(str(npts)) 
    1990         #default:number of data points selected to fit 
     1982        # default:number of data points selected to fit 
    19911983        self.Npts_fit.SetValue(str(npts)) 
    19921984        self.Npts_total.SetEditable(False) 
    1993         self.Npts_total.SetBackgroundColour(\ 
     1985        self.Npts_total.SetBackgroundColour( 
    19941986                                    self.GetParent().GetBackgroundColour()) 
    19951987 
     
    20011993        # send graph_id to page_finder 
    20021994        self._manager.set_graph_id(uid=self.uid, graph_id=self.graph_id) 
    2003         #focus the page 
     1995        # focus the page 
    20041996        if check_data_validity(data): 
    20051997            self.data_box_description.SetForegroundColour(wx.BLUE) 
     
    20132005        self.on_set_focus(None) 
    20142006        self.Refresh() 
    2015         #update model plot with new data information 
     2007        # update model plot with new data information 
    20162008        if flag: 
    2017             #set model view button 
    2018             self.onSmear(None) 
    2019  
    20202009            if self.data.__class__.__name__ == "Data2D": 
    20212010                self.enable2D = True 
     
    20252014                self.model_view.SetLabel("1D Mode") 
    20262015            self.model_view.Disable() 
    2027             #replace data plot on combo box selection 
    2028             #by removing the previous selected data 
     2016            #  replace data plot on combo box selection 
     2017            # by removing the previous selected data 
    20292018            try: 
    20302019                wx.PostEvent(self._manager.parent, 
     
    20332022            except: 
    20342023                pass 
    2035             #plot the current selected data 
     2024            # plot the current selected data 
    20362025            wx.PostEvent(self._manager.parent, 
    20372026                         NewPlotEvent(action="check", plot=self.data, 
     
    20532042            self.reset_page_helper(state) 
    20542043 
    2055             self.select_param(event=None) 
    2056             #Save state_fit 
     2044            self.select_param() 
     2045            # Save state_fit 
    20572046            self.save_current_state_fit() 
    20582047        except: 
     
    20932082        else: 
    20942083            for qx in self.data.x: 
    2095                 if qx >= qmin and qx <= qmax: 
     2084                if qmax >= qx >= qmin: 
    20962085                    npts2fit += 1 
    20972086        return npts2fit 
     
    21222111        # make sure stop button to fit button all the time 
    21232112        self._on_fit_complete() 
    2124         if out == None or not numpy.isfinite(chisqr): 
     2113        if out is None or not numpy.isfinite(chisqr): 
    21252114            raise ValueError, "Fit error occured..." 
    21262115 
     
    21292118        dispersity = '' 
    21302119 
    2131         #Hide textctrl boxes of errors. 
     2120        # Hide textctrl boxes of errors. 
    21322121        self._clear_Err_on_Fit() 
    21332122 
    2134         #Check if chi2 is finite 
    2135         if chisqr != None and numpy.isfinite(chisqr): 
    2136             #format chi2 
     2123        # Check if chi2 is finite 
     2124        if chisqr is not None and numpy.isfinite(chisqr): 
     2125            # format chi2 
    21372126            chi2 = format_number(chisqr, True) 
    21382127            self.tcChi.SetValue(chi2) 
     
    21412130            self.tcChi.SetValue("-") 
    21422131 
    2143         #Hide error title 
     2132        # Hide error title 
    21442133        if self.text2_3.IsShown() and not self.is_mac: 
    21452134            self.text2_3.Hide() 
     
    21482137            if self.enable_disp.GetValue(): 
    21492138                if hasattr(self, "text_disp_1"): 
    2150                     if self.text_disp_1 != None and not self.is_mac: 
     2139                    if self.text_disp_1 is not None and not self.is_mac: 
    21512140                        self.text_disp_1.Hide() 
    21522141        except: 
     
    21552144 
    21562145        i = 0 
    2157         #Set the panel when fit result are list 
     2146        # Set the panel when fit result are list 
    21582147 
    21592148        for item in self.param_toFit: 
    2160             if len(item) > 5 and item != None: 
     2149            if len(item) > 5 and item is not None: 
    21612150 
    21622151                if item[0].IsShown(): 
    2163                     ## reset error value to initial state 
     2152                    # reset error value to initial state 
    21642153                    if not self.is_mac: 
    21652154                        item[3].Hide() 
     
    21682157                        if item[1] == p_name[ind]: 
    21692158                            break 
    2170                     if len(out) > 0 and out[ind] != None: 
     2159                    if len(out) > 0 and out[ind] is not None: 
    21712160                        val_out = format_number(out[ind], True) 
    21722161                        item[2].SetValue(val_out) 
    21732162 
    2174                     if(cov != None and len(cov) == len(out)): 
     2163                    if(cov is not None and len(cov) == len(out)): 
    21752164                        try: 
    2176                             if dispersity != None: 
     2165                            if dispersity is not None: 
    21772166                                if self.enable_disp.GetValue(): 
    21782167                                    if hasattr(self, "text_disp_1"): 
    2179                                         if self.text_disp_1 != None: 
     2168                                        if self.text_disp_1 is not None: 
    21802169                                            if not self.text_disp_1.IsShown()\ 
    2181                                                 and not self.is_mac: 
     2170                                                  and not self.is_mac: 
    21822171                                                self.text_disp_1.Show(True) 
    21832172                        except: 
    21842173                            pass 
    21852174 
    2186                         if cov[ind] != None: 
     2175                        if cov[ind] is not None: 
    21872176                            if numpy.isfinite(float(cov[ind])): 
    21882177                                val_err = format_number(cov[ind], True) 
    2189                                 item[4].SetForegroundColour(wx.BLACK) 
     2178                                item[4].SetForegroundColour(wx.BLACK) 
    21902179                            else: 
    21912180                                val_err = 'NaN' 
     
    21992188            else: 
    22002189                raise ValueError, "onsetValues: Invalid parameters..." 
    2201         #Show error title when any errors displayed 
     2190        # Show error title when any errors displayed 
    22022191        if has_error: 
    22032192            if not self.text2_3.IsShown(): 
    22042193                self.text2_3.Show(True) 
    2205         ## save current state 
     2194        # save current state 
    22062195        self.save_current_state() 
    22072196 
     
    22102199            self.Refresh() 
    22112200        self._mac_sleep(0.1) 
    2212         #plot model ( when drawing, do not update chisqr value again) 
     2201        # plot model ( when drawing, do not update chisqr value again) 
    22132202        self._draw_model(update_chisqr=False, source='fit') 
    22142203 
     
    22262215        # compute weight for the current data 
    22272216        flag_weight = self.get_weight_flag() 
    2228         if is_2D == None: 
     2217        if is_2D is None: 
    22292218            is_2D = self._is_2D() 
    22302219        self._manager.set_fit_weight(uid=self.uid, 
     
    22452234        self._update_paramv_on_fit() 
    22462235 
    2247         if event != None: 
     2236        if event is not None: 
    22482237            tcrtl = event.GetEventObject() 
    22492238            # event case of radio button 
    2250             if tcrtl.GetValue() == True: 
     2239            if tcrtl.GetValue(): 
    22512240                self.dx_min = 0.0 
    22522241                self.dx_max = 0.0 
     
    22662255 
    22672256        self.sizer_set_smearer.Layout() 
    2268         ## we need FitInside here not just self.Layout to ensure all the sizers 
    2269         ## end up with the necessasary space to in the scroll panel. In 
    2270         ## particular the compute and fit buttons end up on top of each other 
    2271         ## PDB Nov 28 2015.  
     2257        # we need FitInside here not just self.Layout to ensure all the sizers 
     2258        # end up with the necessasary space to in the scroll panel. In 
     2259        # particular the compute and fit buttons end up on top of each other 
     2260        # PDB Nov 28 2015. 
    22722261        self.FitInside() 
    22732262 
    2274         if event != None: 
     2263        if event is not None: 
    22752264            event.Skip() 
    2276         #self._undo.Enable(True) 
     2265        # self._undo.Enable(True) 
    22772266        self.save_current_state() 
    22782267        event = PageInfoEvent(page=self) 
     
    23492338                get_pin_max.SetBackgroundColour("pink") 
    23502339                msg = "Model Error:This value can not be negative!!!" 
    2351             elif self.dx_min != None and self.dx_max != None: 
     2340            elif self.dx_min is not None and self.dx_max is not None: 
    23522341                if self._is_2D(): 
    23532342                    data.dqx_data[data.dqx_data == 0] = self.dx_min 
     
    23602349                                           self.dx_max + step / 1.1, 
    23612350                                           step) 
    2362             elif self.dx_min != None: 
     2351            elif self.dx_min is not None: 
    23632352                if self._is_2D(): 
    23642353                    data.dqx_data[data.dqx_data == 0] = self.dx_min 
    23652354                else: 
    23662355                    data.dx[data.dx == 0] = self.dx_min 
    2367             elif self.dx_max != None: 
     2356            elif self.dx_max is not None: 
    23682357                if self._is_2D(): 
    23692358                    data.dqy_data[data.dqy_data == 0] = self.dx_max 
     
    23732362            # 2D need to set accuracy 
    23742363            if self._is_2D(): 
    2375                 self.current_smearer.set_accuracy(accuracy=\ 
    2376                                                   self.smear2d_accuracy) 
    2377  
    2378         if msg != None: 
     2364                self.current_smearer.set_accuracy( 
     2365                    accuracy=self.smear2d_accuracy) 
     2366 
     2367        if msg is not None: 
    23792368            wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
    23802369        else: 
    23812370            get_pin_min.SetBackgroundColour("white") 
    23822371            get_pin_max.SetBackgroundColour("white") 
    2383         ## set smearing value whether or not the data contain the smearing info 
     2372        # set smearing value whether or not the data contain the smearing info 
    23842373 
    23852374        enable_smearer = not self.disable_smearer.GetValue() 
     
    24072396        wx.CallAfter(self.save_current_state) 
    24082397 
    2409         if msg != None: 
     2398        if msg is not None: 
    24102399            return False 
    24112400        else: 
     
    24232412        msg = None 
    24242413        # for event given 
    2425         if event != None: 
     2414        if event is not None: 
    24262415            tcrtl = event.GetEventObject() 
    24272416            # event case of radio button 
     
    24442433        self._show_smear_sizer() 
    24452434        self.sizer_set_smearer.Layout() 
    2446         ## we need FitInside here not just self.Layout to ensure all the sizers 
    2447         ## end up with the necessasary space to in the scroll panel. In 
    2448         ## particular the compute and fit buttons end up on top of each other 
    2449         ## PDB Nov 28 2015.  
     2435        # we need FitInside here not just self.Layout to ensure all the sizers 
     2436        # end up with the necessasary space to in the scroll panel. In 
     2437        # particular the compute and fit buttons end up on top of each other 
     2438        # PDB Nov 28 2015. 
    24502439        self.FitInside() 
    24512440 
    2452         if event != None: 
     2441        if event is not None: 
    24532442            event.Skip() 
    24542443        self.save_current_state() 
    24552444        event = PageInfoEvent(page=self) 
    24562445        wx.PostEvent(self.parent, event) 
    2457         if msg != None: 
     2446        if msg is not None: 
    24582447            wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
    24592448 
     
    25442533 
    25452534        self.current_smearer = smear_selection(data, self.model) 
    2546         ## set smearing value whether or not the data contain the smearing info 
     2535        # set smearing value whether or not the data contain the smearing info 
    25472536        enable_smearer = not self.disable_smearer.GetValue() 
    25482537        self._manager.set_smearer(smearer=self.current_smearer, 
     
    25672556        if self._is_changed_slit(): 
    25682557            msg = self._set_slit_smear() 
    2569         #self._undo.Enable(True) 
     2558        # self._undo.Enable(True) 
    25702559        self.save_current_state() 
    25712560 
    2572         if msg != None: 
     2561        if msg is not None: 
    25732562            return False 
    25742563        else: 
     
    25802569        are computed when fitting 
    25812570        """ 
    2582         if event != None: 
     2571        if event is not None: 
    25832572            event.Skip() 
    25842573        if self.data is None: 
     
    25932582 
    25942583        self.sizer_set_smearer.Layout() 
    2595         ## we need FitInside here not just self.Layout to ensure all the sizers 
    2596         ## end up with the necessasary space to in the scroll panel. In 
    2597         ## particular the compute and fit buttons end up on top of each other 
    2598         ## PDB Nov 28 2015.  
     2584        # we need FitInside here not just self.Layout to ensure all the sizers 
     2585        # end up with the necessasary space to in the scroll panel. In 
     2586        # particular the compute and fit buttons end up on top of each other 
     2587        # PDB Nov 28 2015. 
    25992588        self.FitInside() 
    26002589        self._set_weight() 
    26012590 
    2602         ## set smearing value whether or not the data contain the smearing info 
     2591        # set smearing value whether or not the data contain the smearing info 
    26032592        enable_smearer = not self.disable_smearer.GetValue() 
    26042593        wx.CallAfter(self._manager.set_smearer, uid=self.uid, 
     
    26212610        """ 
    26222611        self._get_smear_info() 
    2623         #renew smear sizer 
     2612        # renew smear sizer 
    26242613        if self.smear_type is not None: 
    26252614            self.smear_description_smear_type.SetValue(str(self.smear_type)) 
     
    26612650        """ 
    26622651        try: 
    2663             if event == None: 
     2652            if event is None: 
    26642653                output = "-" 
    26652654            elif not numpy.isfinite(event.output): 
     
    26962685        self._manager.set_param2fit(self.uid, param2fit) 
    26972686 
    2698     def select_all_param(self, event): 
    2699         """ 
    2700         set to true or false all checkBox given the main checkbox value cb1 
    2701         """ 
    2702         self.param_toFit = [] 
    2703         if  self.parameters != []: 
    2704             if  self.cb1.GetValue(): 
    2705                 for item in self.parameters: 
    2706                     if item[0].IsShown(): 
    2707                         ## for data2D select all to fit 
    2708                         if self.data.__class__.__name__ == "Data2D" or \ 
    2709                                 self.enable2D: 
    2710                             item[0].SetValue(True) 
    2711                             self.param_toFit.append(item) 
    2712                         else: 
    2713                             ## for 1D all parameters except orientation 
    2714                             if not item in self.orientation_params: 
    2715                                 item[0].SetValue(True) 
    2716                                 self.param_toFit.append(item) 
    2717                     else: 
    2718                         item[0].SetValue(False) 
    2719                 #if len(self.fittable_param)>0: 
    2720                 for item in self.fittable_param: 
    2721                     if item[0].IsShown(): 
    2722                         if self.data.__class__.__name__ == "Data2D" or \ 
    2723                                 self.enable2D: 
    2724                             item[0].SetValue(True) 
    2725                             self.param_toFit.append(item) 
    2726                             try: 
    2727                                 if len(self.values[item[1]]) > 0: 
    2728                                     item[0].SetValue(False) 
    2729                             except: 
    2730                                 pass 
    2731  
    2732                         else: 
    2733                             ## for 1D all parameters except orientation 
    2734                             if not item in self.orientation_params_disp: 
    2735                                 item[0].SetValue(True) 
    2736                                 self.param_toFit.append(item) 
    2737                                 try: 
    2738                                     if len(self.values[item[1]]) > 0: 
    2739                                         item[0].SetValue(False) 
    2740                                 except: 
    2741                                     pass 
    2742                     else: 
    2743                         item[0].SetValue(False) 
    2744  
    2745             else: 
    2746                 for item in self.parameters: 
    2747                     item[0].SetValue(False) 
    2748                 for item in self.fittable_param: 
    2749                     item[0].SetValue(False) 
    2750                 self.param_toFit = [] 
    2751  
    2752         self.save_current_state_fit() 
    2753  
    2754         if event != None: 
    2755             #self._undo.Enable(True) 
    2756             ## post state to fit panel 
    2757             event = PageInfoEvent(page=self) 
    2758             wx.PostEvent(self.parent, event) 
    2759         param2fit = [] 
    2760         for item in self.param_toFit: 
    2761             if item[0] and item[0].IsShown(): 
    2762                 param2fit.append(item[1]) 
    2763         self.parent._manager.set_param2fit(self.uid, param2fit) 
    2764  
    2765     def select_param(self, event): 
     2687 
     2688    def select_param(self, event=None): 
    27662689        """ 
    27672690        Select TextCtrl  checked for fitting purpose and stores them 
     
    27702693        self.param_toFit = [] 
    27712694        for item in self.parameters: 
    2772             #Skip t ifhe angle parameters if 1D data 
     2695            # Skip t ifhe angle parameters if 1D data 
    27732696            if self.data.__class__.__name__ != "Data2D" and\ 
    27742697                        not self.enable2D: 
    27752698                if item in self.orientation_params: 
    27762699                    continue 
    2777             #Select parameters to fit for list of primary parameters 
     2700            # Select parameters to fit for list of primary parameters 
    27782701            if item[0].GetValue() and item[0].IsShown(): 
    27792702                if not (item in self.param_toFit): 
     
    27842707                    self.param_toFit.remove(item) 
    27852708 
    2786         #Select parameters to fit for list of fittable parameters 
     2709        # Select parameters to fit for list of fittable parameters 
    27872710        #        with dispersion 
    27882711        for item in self.fittable_param: 
    2789             #Skip t ifhe angle parameters if 1D data 
     2712            # Skip t ifhe angle parameters if 1D data 
    27902713            if self.data.__class__.__name__ != "Data2D" and\ 
    27912714                        not self.enable2D: 
     
    27962719                    self.param_toFit.append(item) 
    27972720            else: 
    2798                 #remove parameters from the fitting list 
     2721                # remove parameters from the fitting list 
    27992722                if item in self.param_toFit: 
    28002723                    self.param_toFit.remove(item) 
    28012724 
    2802         #Calculate num. of angle parameters 
     2725        # Calculate num. of angle parameters 
    28032726        if self.data.__class__.__name__ == "Data2D" or \ 
    28042727                       self.enable2D: 
     
    28062729        else: 
    28072730            len_orient_para = len(self.orientation_params)  # assume even len 
    2808         #Total num. of angle parameters 
     2731        # Total num. of angle parameters 
    28092732        if len(self.fittable_param) > 0: 
    28102733            len_orient_para *= 2 
     
    28172740 
    28182741        self.save_current_state_fit() 
    2819         if event != None: 
    2820             ## post state to fit panel 
     2742        if event is not None: 
     2743            # post state to fit panel 
    28212744            event = PageInfoEvent(page=self) 
    28222745            wx.PostEvent(self.parent, event) 
     
    28442767        self.orientation_params_disp = [] 
    28452768 
    2846         if model == None: 
     2769        if model is None: 
    28472770            self.sizer3.Layout() 
    28482771            self.SetupScrolling() 
     
    28522775        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 
    28532776        sizer = wx.GridBagSizer(5, 5) 
    2854         ## save the current model 
     2777        # save the current model 
    28552778        self.model = model 
    28562779 
    28572780        keys = self.model.getParamList() 
    28582781 
    2859         #list of dispersion parameters 
     2782        # list of dispersion parameters 
    28602783        self.disp_list = self.model.getDispParamList() 
    28612784 
     
    28902813                return -1 
    28912814            # both have a number 
    2892             if num_a != None and num_b != None: 
     2815            if num_a is not None and num_b is not None: 
    28932816                if num_a > num_b: 
    28942817                    return -1 
     
    29032826                    return 1 
    29042827            # one of them has a number 
    2905             elif num_a != None: 
     2828            elif num_a is not None: 
    29062829                return 1 
    2907             elif num_b != None: 
     2830            elif num_b is not None: 
    29082831                return -1 
    29092832            # no numbers 
     
    29112834                return cmp(a.lower(), b.lower()) 
    29122835         
    2913         # keys obtained now from ordered dict, so commenting alphabetical ordering 
    2914         #keys.sort(custom_compare) 
     2836        # keys obtained now from ordered dict, so commenting alphabetical 
     2837        # ordering keys.sort(custom_compare) 
    29152838 
    29162839        iy = 0 
     
    29262849        ix += 1 
    29272850        self.text2_2 = wx.StaticText(self, wx.ID_ANY, 'Value') 
    2928         sizer.Add(self.text2_2, (iy, ix), (1, 1), \ 
     2851        sizer.Add(self.text2_2, (iy, ix), (1, 1), 
    29292852                            wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    29302853        ix += 2 
    29312854        self.text2_3 = wx.StaticText(self, wx.ID_ANY, 'Error') 
    2932         sizer.Add(self.text2_3, (iy, ix), (1, 1), \ 
    2933                             wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
     2855        sizer.Add(self.text2_3, (iy, ix), (1, 1), 
     2856                  wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    29342857        if not self.is_mac: 
    29352858            self.text2_3.Hide() 
    29362859        ix += 1 
    29372860        self.text2_min = wx.StaticText(self, wx.ID_ANY, 'Min') 
    2938         sizer.Add(self.text2_min, (iy, ix), (1, 1), \ 
    2939                             wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    2940         #self.text2_min.Hide() 
     2861        sizer.Add(self.text2_min, (iy, ix), (1, 1), 
     2862                  wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
     2863        # self.text2_min.Hide() 
    29412864        ix += 1 
    29422865        self.text2_max = wx.StaticText(self, wx.ID_ANY, 'Max') 
    2943         sizer.Add(self.text2_max, (iy, ix), (1, 1), \ 
    2944                             wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    2945         #self.text2_max.Hide() 
     2866        sizer.Add(self.text2_max, (iy, ix), (1, 1), 
     2867                  wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
     2868        # self.text2_max.Hide() 
    29462869        ix += 1 
    29472870        self.text2_4 = wx.StaticText(self, wx.ID_ANY, '[Units]') 
    2948         sizer.Add(self.text2_4, (iy, ix), (1, 1), \ 
    2949                             wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
     2871        sizer.Add(self.text2_4, (iy, ix), (1, 1), 
     2872                  wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    29502873        self.text2_4.Hide() 
    29512874 
     
    29532876        for item in keys: 
    29542877 
    2955             if not item in self.disp_list and not item in \ 
     2878            if item not in self.disp_list and not item in \ 
    29562879                    self.model.orientation_params: 
    29572880 
    2958                 ##prepare a spot to store errors 
    2959                 if not item in self.model.details: 
     2881                # prepare a spot to store errors 
     2882                if item not in self.model.details: 
    29602883                    self.model.details[item] = ["", None, None] 
    29612884 
    29622885                iy += 1 
    29632886                ix = 0 
    2964                 if (self.model.__class__ in \ 
    2965                     self.model_list_box["Multi-Functions"] or \ 
     2887                if (self.model.__class__ in 
     2888                    self.model_list_box["Multi-Functions"] or 
    29662889                    self.temp_multi_functional)\ 
    29672890                    and (item in self.model.non_fittable): 
    29682891                    non_fittable_name = wx.StaticText(self, wx.ID_ANY, item) 
    2969                     sizer.Add(non_fittable_name, (iy, ix), (1, 1), \ 
     2892                    sizer.Add(non_fittable_name, (iy, ix), (1, 1), 
    29702893                            wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 21) 
    2971                     ## add parameter value 
     2894                    # add parameter value 
    29722895                    ix += 1 
    29732896                    value = self.model.getParam(item) 
    29742897                    if len(self.model.fun_list) > 0: 
    2975                         #num = item.split('_')[1][5:7] 
     2898                        # num = item.split('_')[1][5:7] 
    29762899                        fun_box = wx.ComboBox(self, wx.ID_ANY, size=(100, -1), 
    29772900                                    style=wx.CB_READONLY, name='%s' % item) 
    29782901                        self._set_fun_box_list(fun_box) 
    29792902                        fun_box.SetSelection(0) 
    2980                         #self.fun_box.SetToolTipString("A function 
     2903                        # self.fun_box.SetToolTipString("A function 
    29812904                        #    describing the interface") 
    29822905                        wx.EVT_COMBOBOX(fun_box, wx.ID_ANY, self._on_fun_box) 
     
    29852908                                                size=(_BOX_WIDTH, 20), 
    29862909                                style=wx.TE_PROCESS_ENTER, name='%s' % item) 
    2987                         fun_box.SetToolTipString(\ 
     2910                        fun_box.SetToolTipString( 
    29882911                                "Hit 'Enter' after typing to update the plot.") 
    29892912                        fun_box.SetValue(format_number(value, True)) 
     
    29932916                                                None, None]) 
    29942917                else: 
    2995                     ## add parameters name with checkbox for selecting to fit 
     2918                    # add parameters name with checkbox for selecting to fit 
    29962919                    cb = wx.CheckBox(self, wx.ID_ANY, item) 
    29972920                    cb.SetValue(CHECK_STATE) 
    29982921                    cb.SetToolTipString(" Check mark to fit.") 
    2999                     #cb.SetValue(True) 
     2922                    # cb.SetValue(True) 
    30002923                    wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) 
    30012924 
     
    30032926                              wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 5) 
    30042927 
    3005                     ## add parameter value 
     2928                    # add parameter value 
    30062929                    ix += 1 
    30072930                    value = self.model.getParam(item) 
    30082931                    ctl1 = ModelTextCtrl(self, wx.ID_ANY, size=(_BOX_WIDTH, 20), 
    30092932                                         style=wx.TE_PROCESS_ENTER) 
    3010                     ctl1.SetToolTipString(\ 
     2933                    ctl1.SetToolTipString( 
    30112934                                "Hit 'Enter' after typing to update the plot.") 
    30122935                    ctl1.SetValue(format_number(value, True)) 
    30132936                    sizer.Add(ctl1, (iy, ix), (1, 1), wx.EXPAND) 
    3014                     ## text to show error sign 
     2937                    # text to show error sign 
    30152938                    ix += 1 
    30162939                    text2 = wx.StaticText(self, wx.ID_ANY, '+/-') 
    3017                     sizer.Add(text2, (iy, ix), (1, 1), \ 
     2940                    sizer.Add(text2, (iy, ix), (1, 1), 
    30182941                              wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    30192942                    if not self.is_mac: 
     
    30762999        iy += 1 
    30773000        ix = 0 
    3078         #Add tile for orientational angle 
     3001        # Add tile for orientational angle 
    30793002        for item in keys: 
    30803003            if item in self.model.orientation_params: 
     
    30833006                mag_on_button.SetToolTipString("Turn Pol Beam/Mag scatt on/off") 
    30843007                mag_on_button.Bind(wx.EVT_BUTTON, self._on_mag_on) 
    3085                 mag_angle_help_button = wx.Button(self, wx.ID_ANY, "Magnetic angles?") 
     3008                mag_angle_help_button = wx.Button(self, wx.ID_ANY, 
     3009                                                  "Magnetic angles?") 
    30863010                mag_angle_help_button.SetToolTipString("see angle definitions") 
    30873011                mag_help_button = wx.Button(self, wx.ID_ANY, "Mag HELP") 
    30883012                mag_help_button.SetToolTipString("Help on pol beam/mag fitting") 
    30893013                mag_help_button.Bind(wx.EVT_BUTTON, self._on_mag_help) 
    3090                 mag_angle_help_button.Bind(wx.EVT_BUTTON, \ 
     3014                mag_angle_help_button.Bind(wx.EVT_BUTTON, 
    30913015                                            self._on_mag_angle_help) 
    30923016                sizer.Add(orient_angle, (iy, ix), (1, 1), 
     
    31013025                          wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    31023026 
    3103                 #handle the magnetic buttons 
    3104                 #clean this up so that assume mag is off then turn  
    3105                 #all buttons on IF mag has mag and has 2D 
     3027                # handle the magnetic buttons 
     3028                # clean this up so that assume mag is off then turn 
     3029                # all buttons on IF mag has mag and has 2D 
    31063030                if not self._has_magnetic: 
    31073031                    mag_on_button.Show(False) 
     
    31293053                break 
    31303054 
    3131         #For Gaussian only 
     3055        # For Gaussian only 
    31323056        if type.lower() != "array": 
    31333057            for item in self.model.orientation_params: 
     
    31353059                    if item in self.model.magnetic_params: 
    31363060                        continue 
    3137                 if not item in self.disp_list: 
    3138                     ##prepare a spot to store min max 
    3139                     if not item in self.model.details: 
     3061                if item not in self.disp_list: 
     3062                    # prepare a spot to store min max 
     3063                    if item not in self.model.details: 
    31403064                        self.model.details[item] = ["", None, None] 
    31413065 
    31423066                    iy += 1 
    31433067                    ix = 0 
    3144                     ## add parameters name with checkbox for selecting to fit 
     3068                    # add parameters name with checkbox for selecting to fit 
    31453069                    cb = wx.CheckBox(self, wx.ID_ANY, item) 
    31463070                    cb.SetValue(CHECK_STATE) 
     
    31553079                              wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 5) 
    31563080 
    3157                     ## add parameter value 
     3081                    # add parameter value 
    31583082                    ix += 1 
    31593083                    value = self.model.getParam(item) 
    31603084                    ctl1 = ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 
    31613085                                         style=wx.TE_PROCESS_ENTER) 
    3162                     ctl1.SetToolTipString(\ 
     3086                    ctl1.SetToolTipString( 
    31633087                                "Hit 'Enter' after typing to update the plot.") 
    31643088                    ctl1.SetValue(format_number(value, True)) 
     
    31693093                        ctl1.Hide() 
    31703094                    sizer.Add(ctl1, (iy, ix), (1, 1), wx.EXPAND) 
    3171                     ## text to show error sign 
     3095                    # text to show error sign 
    31723096                    ix += 1 
    31733097                    text2 = wx.StaticText(self, -1, '+/-') 
    3174                     sizer.Add(text2, (iy, ix), (1, 1), \ 
     3098                    sizer.Add(text2, (iy, ix), (1, 1), 
    31753099                              wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    31763100 
     
    32373161        iy += 1 
    32383162        box_description.SetForegroundColour(wx.BLUE) 
    3239         #Display units text on panel 
     3163        # Display units text on panel 
    32403164        for item in keys: 
    32413165            if item in self.model.details: 
    32423166                self.text2_4.Show() 
    3243         #Fill the list of fittable parameters 
     3167        # Fill the list of fittable parameters 
    32443168        self.get_all_checked_params() 
    32453169        self.save_current_state_fit() 
     
    32533177        Get key stroke event 
    32543178        """ 
    3255         if self.data == None: 
     3179        if self.data is None: 
    32563180            return 
    32573181        # Figuring out key combo: Cmd for copy, Alt for paste 
  • src/sas/sasgui/perspectives/fitting/fitpanel.py

    re6de6b8 rc8e1996  
    187187        """ 
    188188 
    189         # get number of pages 
    190         nop = self.GetPageCount() 
    191189        # use while-loop, for-loop will not do the job well. 
    192         while (nop > 0): 
     190        while (self.GetPageCount() > 0): 
    193191            # delete the first page until no page exists 
    194192            page = self.GetPage(0) 
     
    197195            self._close_helper(selected_page=page) 
    198196            self.DeletePage(0) 
    199             nop = self.GetPageCount() 
    200197        # Clear list of names 
    201198        self.fit_page_name = {} 
     
    240237        # close all panels only when svs file opened 
    241238        self.close_all() 
    242         self._manager.mypanels = [] 
    243239        self.sim_page = None 
    244240        self.batch_page = None 
     
    248244        close page and remove all references to the closed page 
    249245        """ 
    250         nbr_page = self.GetPageCount() 
    251246        selected_page = self.GetPage(self.GetSelection()) 
    252         if nbr_page == 1: 
     247        if self.GetPageCount() == 1: 
    253248            if selected_page.get_data() is not None: 
    254249                if event is not None: 
     
    293288        copy a dictionary of model into its own dictionary 
    294289 
    295         :param m_dict: dictionnary made of model name as key and model class 
     290        :param dict: dictionnary made of model name as key and model class 
    296291            as value 
    297292        """ 
     
    320315        if caption == "Const & Simul Fit": 
    321316            self.sim_page = SimultaneousFitPage(self, page_finder=page_finder, 
    322                                                  id= wx.ID_ANY, batch_on=False) 
     317                                                 id=wx.ID_ANY, batch_on=False) 
    323318            self.sim_page.window_caption = caption 
    324319            self.sim_page.window_name = caption 
     
    397392            raise ValueError, "Fitpanel delete_data expect list of id" 
    398393        else: 
    399             n = self.GetPageCount() 
    400394            for page in self.opened_pages.values(): 
    401395                pos = self.GetPageIndex(page) 
     
    441435        if data_1d_list and data_2d_list: 
    442436            # need to warning the user that this batch is a special case 
    443             from sas.sasgui.perspectives.fitting.fitting_widgets import BatchDataDialog 
     437            from sas.sasgui.perspectives.fitting.fitting_widgets import \ 
     438                BatchDataDialog 
    444439            dlg = BatchDataDialog(self) 
    445440            if dlg.ShowModal() == wx.ID_OK: 
     
    461456                page = self.add_empty_page() 
    462457            if data_1d_list and not data_2d_list: 
    463                 #only on type of data 
     458                # only on type of data 
    464459                page.fill_data_combobox(data_1d_list) 
    465460            elif not data_1d_list and data_2d_list: 
     
    477472        Add a fitting page on the notebook contained by fitpanel 
    478473 
    479         :param data: data to fit 
     474        :param data_list: data to fit 
    480475 
    481476        :return panel : page just added for further used. 
  • src/sas/sasgui/perspectives/fitting/fitting.py

    rec72ceb r1a5d5f2  
    15211521            for uid in page_id: 
    15221522                res = result[index] 
     1523                fit_msg = res.mesg 
    15231524                if res.fitness is None or \ 
    15241525                    not numpy.isfinite(res.fitness) or \ 
    15251526                    numpy.any(res.pvec == None) or \ 
    15261527                    not numpy.all(numpy.isfinite(res.pvec)): 
    1527                     msg = "Fitting did not converge!!!" 
    1528                     evt = StatusEvent(status=msg, info="warning", type="stop") 
    1529                     wx.PostEvent(self.parent, evt) 
     1528                    fit_msg += "\nFitting did not converge!!!" 
    15301529                    wx.CallAfter(self._update_fit_button, page_id) 
    15311530                else: 
     
    15501549                        wx.CallAfter(cpage._on_fit_complete) 
    15511550                    except KeyboardInterrupt: 
    1552                         msg = "Singular point: Fitting Stoped." 
    1553                         evt = StatusEvent(status=msg, info="info", type="stop") 
    1554                         wx.PostEvent(self.parent, evt) 
     1551                        fit_msg += "\nSingular point: Fitting stopped." 
    15551552                    except: 
    1556                         msg = "Singular point: Fitting Error occurred." 
    1557                         evt = StatusEvent(status=msg, info="error", type="stop") 
    1558                         wx.PostEvent(self.parent, evt) 
     1553                        fit_msg += "\nSingular point: Fitting error occurred." 
     1554                if fit_msg: 
     1555                   evt = StatusEvent(status=fit_msg, info="warning", type="stop") 
     1556                   wx.PostEvent(self.parent, evt) 
    15591557 
    15601558        except: 
  • src/sas/sasgui/perspectives/fitting/media/fitting_help.rst

    r3e1c9e5 r26c8be3  
    163163^^^^^^^^^^^^^^^^ 
    164164 
     165Relatively straightforward models can be programmed directly from the SasView GUI  
     166using the *New Plugin Model Function*. 
     167 
    165168.. image:: new_model.bmp 
    166169 
    167 A model template generated by this option can be viewed and further modified using 
     170When using this feature, be aware that even if your code has errors, including  
     171syntax errors, a model file is still generated. When you then correct the errors  
     172and click 'Apply' again to re-compile you will get an error informing you that  
     173the model already exists if the 'Overwrite' box is not checked. In this case you  
     174will need to supply a new model function name. By default the 'Overwrite' box is  
     175*checked*\ . 
     176 
     177Also note that the 'Fit Parameters' have been split into two sections: those which  
     178can be polydisperse (shape and orientation parameters) and those which are not 
     179(eg, scattering length densities). 
     180 
     181A model file generated by this option can be viewed and further modified using 
    168182the :ref:`Advanced_Plugin_Editor` . 
    169  
    170 *NB: "Fit Parameters" has been split into two sections, those which can be 
    171 polydisperse (shape and orientation parameters) and those which are not 
    172 (scattering length densities, for example).* 
    173183 
    174184Sum|Multi(p1,p2) 
  • src/sas/sasgui/perspectives/fitting/media/plugin.rst

    r3e1c9e5 r20cfa23  
    1111There are essentially three ways to generate new fitting models for SasView: 
    1212 
    13 * Using the SasView :ref:`New_Plugin_Model` helper dialog (best for beginners and/or relatively simple models) 
    14 * By copying/editing an existing model (this can include models generated by the *New Plugin Model* dialog) in the :ref:`Python_shell` or :ref:`Advanced_Plugin_Editor` as described below (suitable for all use cases) 
    15 * By writing a model from scratch outside of SasView (only recommended for code monkeys!) 
     13* Using the SasView :ref:`New_Plugin_Model` helper dialog (best for beginners 
     14  and/or relatively simple models) 
     15* By copying/editing an existing model (this can include models generated by 
     16  the *New Plugin Model* dialog) in the :ref:`Python_shell` or 
     17  :ref:`Advanced_Plugin_Editor` as described below (suitable for all use cases) 
     18* By writing a model from scratch outside of SasView (only recommended for 
     19  code monkeys!) 
    1620 
    1721Overview 
     
    2327 
    2428the next time SasView is started it will compile the plugin and add 
    25 it to the list of *Plugin Models* in a FitPage. 
     29it to the list of *Customized Models* in a FitPage. 
    2630 
    2731SasView models can be of three types: 
     
    5761- If necessary use underscore to separate words (i.e. barbell not BarBell or 
    5862  broad_peak not BroadPeak) 
    59 - Do not include “modelâ€ᅵ in the name (i.e. barbell not BarBellModel) 
     63- Do not include "model" in the name (i.e. barbell not BarBellModel) 
    6064 
    6165 
     
    479483    } 
    480484 
    481 The C model operates on a single $q$ value at a time.  The code will be 
    482 run in parallel across different $q$ values, either on the graphics card 
    483 or the processor. 
    484  
    485 Rather than returning NAN from Iq, you must define the *INVALID(v)*.  The 
    486 *v* parameter lets you access all the parameters in the model using 
    487 *v.par1*, *v.par2*, etc. For example:: 
    488  
    489     #define INVALID(v) (v.bell_radius < v.radius) 
    490  
    491485*Iqxy* is similar to *Iq*, except it uses parameters *qx, qy* instead of *q*, 
    492 and it includes orientation parameters. As in python models, *form_volume* 
    493 includes only the volume parameters.  *Iqxy* will default to 
    494 *Iq(sqrt(qx**2 + qy**2), par1, ...)* and *form_volume* will default to 1.0. 
    495  
    496 The C code follows the C99 standard, including the usual math functions, 
    497 as defined in 
    498 `OpenCL <https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/mathFunctions.html>`_. 
    499  
    500 The standard constants and functions include the following:: 
    501  
    502     M_PI = pi 
    503     M_PI_2 = pi/2 
    504     M_PI_4 = pi/4 
    505     M_E = e 
    506     M_SQRT1_2 = 1/sqrt(2) 
    507     NAN = NaN 
    508     INFINITY = 1/0 
    509     erf(x) = error function 
    510     erfc(x) = 1-erf(x) 
    511     expm1(x) = exp(x) - 1 
    512     tgamma(x) = gamma function 
    513  
    514 Some non-standard constants and functions are also provided:: 
    515  
    516     M_PI_180 = pi/180 
    517     M_4PI_3 = 4pi/3 
    518     square(x) = x*x 
    519     cube(x) = x*x*x 
    520     sinc(x) = sin(x)/x, with sin(0)/0 -> 1 
    521     SINCOS(x, s, c) sets s=sin(angle) and c=cos(angle) 
    522     powr(x, y) = x^y for x >= 0 
    523     pown(x, n) = x^n for n integer 
    524  
    525 **source=['lib/fn.c', ...]** includes the listed C source files in the 
     486and it includes orientation parameters. 
     487 
     488*form_volume* defines the volume of the shape. As in python models, it  
     489includes only the volume parameters. 
     490 
     491*Iqxy* will default to *Iq(sqrt(qx**2 + qy**2), par1, ...)* and 
     492*form_volume* will default to 1.0. 
     493 
     494**source=['fn.c', ...]** includes the listed C source files in the 
    526495program before *Iq* and *Iqxy* are defined. This allows you to extend the 
    527 library of available C functions. Additional special functions and 
    528 scattering calculations are defined in 
    529 `sasmodels/models/lib <https://github.com/SasView/sasmodels/tree/master/sasmodels/models/lib>`_, 
    530 including:: 
    531  
    532     sph_j1c(x) = 3 j1(x)/x = 3 (sin(x) - x cos(x))/x^3  [spherical bessel function] 
    533     sas_J1c(x) = 2 J1(x)/x  [bessel function of the first kind] 
    534     sas_gamma(x) = gamma function  [tgamma is unstable below 1] 
    535     sas_erf(x) = error function [erf is broken on some Intel OpenCL drivers] 
    536     sas_erfc(x) = 1-erf(x) 
    537     sas_J0(x) = J0(x) 
    538     sas_J1(x) = J1(x) 
    539     sas_JN(x) = JN(x) 
    540     Si(x) = integral sin(z)/z from 0 to x 
    541     Gauss76Wt = gaussian quadrature weights for 76 point integral 
    542     Gauss76Z = gaussian quadrature values for 76 point integral 
    543  
    544 These functions have been tuned to be fast and numerically stable down 
    545 to $q=0$ even in single precision.  In some cases they work around bugs 
    546 which appear on some platforms but not others. So use them where needed!!! 
     496library of C functions available to your model. 
    547497 
    548498Models are defined using double precision declarations for the 
    549 parameters and return values.  Declarations and constants will be converted 
    550 to float or long double depending on the precision requested. 
     499parameters and return values.  When a model is run using single 
     500precision or long double precision, each variable is converted 
     501to the target type, depending on the precision requested. 
    551502 
    552503**Floating point constants must include the decimal point.**  This allows us 
     
    558509use the builtin constant M_PI rather than 4*atan(1); it is faster and smaller! 
    559510 
    560 FLOAT_SIZE is the number of bytes in the converted variables. If your 
    561 algorithm depends on precision (which is not uncommon for numerical 
    562 algorithms), use the following:: 
    563  
    564     #if FLOAT_SIZE>4 
    565     ... code for double precision ... 
    566     #else 
    567     ... code for single precision ... 
    568     #endif 
    569  
    570 A value defined as SAS_DOUBLE will stay double precision; this should 
    571 not be used since some graphics cards do not support double precision. 
    572  
     511The C model operates on a single $q$ value at a time.  The code will be 
     512run in parallel across different $q$ values, either on the graphics card 
     513or the processor. 
     514 
     515Rather than returning NAN from Iq, you must define the *INVALID(v)*.  The 
     516*v* parameter lets you access all the parameters in the model using 
     517*v.par1*, *v.par2*, etc. For example:: 
     518 
     519    #define INVALID(v) (v.bell_radius < v.radius) 
     520 
     521Special Functions 
     522................. 
     523 
     524The C code follows the C99 standard, with the usual math functions, 
     525as defined in 
     526`OpenCL <https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/mathFunctions.html>`_. 
     527This includes the following: 
     528 
     529    M_PI, M_PI_2, M_PI_4, M_SQRT1_2, M_E: 
     530        $\pi$, $\pi/2$, $\pi/4$, $1/\sqrt{2}$ and Euler's constant $e$ 
     531    exp, log, pow(x,y), expm1, sqrt: 
     532        Power functions $e^x$, $\ln x$, $x^y$, $e^x - 1$, $\sqrt{x}$. 
     533        The function expm1(x) is accurate across all $x$, including $x$ 
     534        very close to zero. 
     535    sin, cos, tan, asin, acos, atan: 
     536        Trigonometry functions and inverses, operating on radians. 
     537    sinh, cos, tanh, asinh, acosh, atanh: 
     538        Hyperbolic trigonometry functions. 
     539    atan2(y,x): 
     540        Angle from the $x$\ -axis to the point $(x,y)$, which is equal to 
     541        $\tan^{-1}(y/x)$ corrected for quadrant.  That is, if $x$ and $y$ are 
     542        both negative, then atan2(y,x) returns a value in quadrant III where 
     543        atan(y/x) would return a value in quadrant I. Similarly for 
     544        quadrants II and IV when $x$ and $y$ have opposite sign. 
     545    fmin(x,y), fmax(x,y), trunc, rint: 
     546        Floating point functions.  rint(x) returns the nearest integer. 
     547    NAN: 
     548        NaN, Not a Number, $0/0$.  Use isnan(x) to test for NaN.  Note that 
     549        you cannot use :code:`x == NAN` to test for NaN values since that 
     550        will always return false.  NAN does not equal NAN! 
     551    INFINITY: 
     552        $\infty, 1/0$.  Use isinf(x) to test for infinity, or isfinite(x) 
     553        to test for finite and not NaN. 
     554    erf, erfc, tgamma, lgamma:  **do not use** 
     555        Special functions that should be part of the standard, but are missing 
     556        or inaccurate on some platforms. Use sas_erf, sas_erfc and sas_gamma 
     557        instead (see below). Note: lgamma(x) has not yet been tested. 
     558 
     559Some non-standard constants and functions are also provided: 
     560 
     561    M_PI_180, M_4PI_3: 
     562        $\pi/{180}$, $\tfrac{4}{3}\pi$ 
     563    SINCOS(x, s, c): 
     564        Macro which sets s=sin(x) and c=cos(x). The variables *c* and *s* 
     565        must be declared first. 
     566    square(x): 
     567        $x^2$ 
     568    cube(x): 
     569        $x^3$ 
     570    sinc(x): 
     571        $\sin(x)/x$, with limit $\sin(0)/0 = 1$. 
     572    powr(x, y): 
     573        $x^y$ for $x \ge 0$; this is faster than general $x^y$ on some GPUs. 
     574    pown(x, n): 
     575        $x^n$ for $n$ integer; this is faster than general $x^n$ on some GPUs. 
     576    FLOAT_SIZE: 
     577        The number of bytes in a floating point value.  Even though all 
     578        variables are declared double, they may be converted to single 
     579        precision float before running. If your algorithm depends on 
     580        precision (which is not uncommon for numerical algorithms), use 
     581        the following:: 
     582 
     583            #if FLOAT_SIZE>4 
     584            ... code for double precision ... 
     585            #else 
     586            ... code for single precision ... 
     587            #endif 
     588    SAS_DOUBLE: 
     589        A replacement for :code:`double` so that the declared variable will 
     590        stay double precision; this should generally not be used since some 
     591        graphics cards do not support double precision.  There is no provision 
     592        for forcing a constant to stay double precision. 
     593 
     594The following special functions and scattering calculations are defined in 
     595`sasmodels/models/lib <https://github.com/SasView/sasmodels/tree/master/sasmodels/models/lib>`_. 
     596These functions have been tuned to be fast and numerically stable down 
     597to $q=0$ even in single precision.  In some cases they work around bugs 
     598which appear on some platforms but not others. So use them where needed!!! 
     599 
     600    polevl(x, c, n): 
     601        Polynomial evaluation $p(x) = \sum_{i=0}^n c_i x^{n-i}$ using Horner's 
     602        method so it is faster and more accurate. 
     603 
     604        :code:`source = ["lib/polevl.c", ...]` 
     605 
     606    sas_gamma: 
     607        Gamma function $\text{sas_gamma}(x) = \Gamma(x)$.  The standard math 
     608        library gamma function, tgamma(x) is unstable below 1 on some platforms. 
     609 
     610        :code:`source = ["lib/sasgamma.c", ...]` 
     611 
     612    erf, erfc: 
     613        Error function 
     614        $\text{erf}(x) = \frac{1}{\sqrt\pi}\int_0^x e^{-t^2}\,dt$ 
     615        and complementary error function 
     616        $\text{erfc}(x) = \frac{1}{\sqrt\pi}\int_x^\inf e^{-t^2}\,dt$. 
     617        The standard math library erf and erfc are slower and broken 
     618        on some platforms. 
     619 
     620        :code:`source = ["lib/polevl.c", "lib/sas_erf.c", ...]` 
     621 
     622    sas_J0: 
     623        Bessel function of the first kind where 
     624        $J_0(x) = \frac{1}{\pi}\int_0^\pi \cos(x\sin(\tau))\,d\tau$. 
     625 
     626        :code:`source = ["lib/polevl.c", "lib/sas_J0.c", ...]` 
     627 
     628    sas_J1: 
     629        Bessel function of the first kind where 
     630        $J_1(x) = \frac{1}{\pi}\int_0^\pi \cos(\tau - x\sin(\tau))\,d\tau$. 
     631 
     632        :code:`source = ["lib/polevl.c", "lib/sas_J1.c", ...]` 
     633 
     634    sas_JN: 
     635        Bessel function of the first kind where 
     636        $J_n(x) = \frac{1}{\pi}\int_0^\pi \cos(n\tau - x\sin(\tau))\,d\tau$. 
     637 
     638        :code:`source = ["lib/polevl.c", "lib/sas_J0.c", "lib/sas_J1.c", "lib/sas_JN.c", ...]` 
     639 
     640    Si: 
     641        Sine integral $\text{Si}(x) = \int_0^x \tfrac{\sin t}{t}\,dt$. 
     642 
     643        :code:`soure = ["lib/Si.c", ...]` 
     644 
     645    sph_j1c(qr): 
     646        Spherical Bessel form 
     647        $F(qr) = 3 j_1(qr)/(qr) = 3 (\sin(qr) - qr \cos(qr))/{(qr)^3}$, 
     648        with a limiting value of 1 at $qr=0$.  This function uses a Taylor 
     649        series for small $qr$ for numerical accuracy. 
     650 
     651        :code:`source = ["lib/sph_j1c.c", ...]` 
     652 
     653    sas_J1c(qr): 
     654        Bessel form $F(qr) = 2 J_1(qr)/{(qr)}$, with a limiting value of 1 at $qr=0$. 
     655 
     656        :code:`source = ["lib/polevl.c", "lib/sas_J1.c", ...]` 
     657 
     658    Gauss76z[i], Gauss76Wt[i]: 
     659        Points $z_i$ and weights $w_i$ for 76-point Gaussian quadrature, 
     660        computing $\int_{-1}^1 f(z)\,dz \approx \sum_{i=1}^{76} w_i f(z_i)$. 
     661        Similar arrays are available in :code:`gauss20.c` for 20 point 
     662        quadrature and in :code:`gauss150.c` for 150 point quadrature. 
     663 
     664        :code:`source = ["gauss76.c", ...]` 
     665 
     666Problems with C models 
     667...................... 
     668 
     669The graphics processor (GPU) in your computer is a specialized computer tuned 
     670for certain kinds of problems.  This leads to strange restrictions that you 
     671need to be aware of.  Your code may work fine on some platforms or for some 
     672models, but then return bad values on other platforms.  Some examples of 
     673particular problems: 
     674 
     675  **(1) Code is too complex, or uses too much memory.**  GPU devices only have a 
     676  limited amount of memory available for each processor.  If you run programs 
     677  which take too much memory, then rather than running multiple values in parallel 
     678  as it usually does, the GPU may only run a single version of the code at a 
     679  time, making it slower than running on the CPU.  It may fail to run on 
     680  some platforms, or worse, cause the screen to go blank or the system to reboot. 
     681 
     682  **(2) Code takes too long.**  Because GPU devices are used for the computer 
     683  display, the OpenCL drivers are very careful about the amount of time they 
     684  will allow any code to run.  For example, on OS X, the model will stop running 
     685  after 5 seconds regardless of whether the computation is complete.  You may end up 
     686  with only some of your 2D array defined, with the rest containing random 
     687  data. Or it may cause the screen to go blank or the system to reboot. 
     688 
     689  **(3) Memory is not aligned**.  The GPU hardware is specialized to operate on 
     690  multiple values simultaneously.  To keep the GPU simple the values in memory 
     691  must be aligned with the different GPU compute engines.  Not following these 
     692  rules can lead to unexpected values being loaded into memory, and wrong answers 
     693  computed.  The conclusion from a very long and strange debugging session was 
     694  that any arrays that you declare in your model should be a multiple of four. 
     695  For example:: 
     696 
     697      double Iq(q, p1, p2, ...) 
     698      { 
     699          double vector[8];  // Only going to use seven slots, but declare 8 
     700          ... 
     701      } 
     702 
     703The first step when your model is behaving strangely is to set **single=False**. 
     704This automatically restricts the model to only run on the CPU, or on high-end 
     705GPU cards.  There can still be problems even on high-end cards, so you can force 
     706the model off the GPU by setting **opencl=False**.  This runs the model 
     707as a normal C program without any GPU restrictions so you know that 
     708strange results are probably from your code rather than the environment.  Once 
     709the code is debugged, you can compare your output to the output on the GPU. 
     710 
     711Although it can be difficult to get your model to work on the GPU, the reward 
     712can be a model that runs 1000x faster on a good card.  Even your laptop may 
     713show a 50x improvement or more over the equivalent pure python model. 
    573714 
    574715External C Models 
     
    577718External C models are very much like embedded C models, except that 
    578719*Iq*, *Iqxy* and *form_volume* are defined in an external source file 
    579 loaded using the *source=[...]*  method. You need to supply the function 
     720loaded using the *source=[...]* statement. You need to supply the function 
    580721declarations for each of these that you need instead of building them 
    581722automatically from the parameter table. 
     
    804945.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
    805946 
    806 .. note::  This help document was last changed by Steve King, 10Oct2016 
     947.. note::  This help document was last changed by Steve King, 25Oct2016 
  • src/sas/sasgui/perspectives/fitting/models.py

    r5de7f69 r313c5c9  
    356356        """ 
    357357        if int(evt.GetId()) in self.form_factor_dict.keys(): 
    358             from sas.sascalc.fit.MultiplicationModel import MultiplicationModel 
     358            from sasmodels.sasview_model import MultiplicationModel 
    359359            self.model_dictionary[MultiplicationModel.__name__] = MultiplicationModel 
    360360            model1, model2 = self.form_factor_dict[int(evt.GetId())] 
  • src/sas/sasgui/perspectives/fitting/pagestate.py

    r467202f rc8e1996  
    4646                            ["npts", "npts", "float"], 
    4747                            ["categorycombobox", "categorycombobox", "string"], 
    48                             ["formfactorcombobox", "formfactorcombobox", "string"], 
    49                             ["structurecombobox", "structurecombobox", "string"], 
     48                            ["formfactorcombobox", "formfactorcombobox", 
     49                             "string"], 
     50                            ["structurecombobox", "structurecombobox", 
     51                             "string"], 
    5052                            ["multi_factor", "multi_factor", "float"], 
    5153                            ["magnetic_on", "magnetic_on", "bool"], 
     
    6567                            ["smearer", "smearer", "float"], 
    6668                            ["smear_type", "smear_type", "string"], 
    67                             ["dq_l", "dq_l", "string"], 
    68                             ["dq_r", "dq_r", "string"], 
     69                            ["dq_l", "dq_l", "float"], 
     70                            ["dq_r", "dq_r", "float"], 
    6971                            ["dx_max", "dx_max", "float"], 
    7072                            ["dx_min", "dx_min", "float"], 
     
    8082                            ["str_parameters", "str_parameters"], 
    8183                            ["orientation_parameters", "orientation_params"], 
    82                             ["dispersity_parameters", "orientation_params_disp"], 
     84                            ["dispersity_parameters", 
     85                             "orientation_params_disp"], 
    8386                            ["fixed_param", "fixed_param"], 
    8487                            ["fittable_param", "fittable_param"]] 
     
    120123            try: 
    121124                return node.get(item[0]).strip() == "True" 
    122             except: 
     125            except Exception: 
    123126                return None 
    124127        else: 
    125128            try: 
    126129                return float(node.get(item[0])) 
    127             except: 
     130            except Exception: 
    128131                return None 
    129132 
     
    188191        # page name 
    189192        self.page_name = "" 
    190         # Contains link between model, all its parameters, and panel organization 
     193        # Contains link between model, its parameters, and panel organization 
    191194        self.parameters = [] 
    192195        # String parameter list that can not be fitted 
     
    305308        obj.fittable_param = copy.deepcopy(self.fittable_param) 
    306309        obj.orientation_params = copy.deepcopy(self.orientation_params) 
    307         obj.orientation_params_disp = copy.deepcopy(self.orientation_params_disp) 
     310        obj.orientation_params_disp = \ 
     311            copy.deepcopy(self.orientation_params_disp) 
    308312        obj.enable_disp = copy.deepcopy(self.enable_disp) 
    309313        obj.disable_disp = copy.deepcopy(self.disable_disp) 
     
    397401        rep += "data : %s\n" % str(self.data) 
    398402        rep += "Plotting Range: min: %s, max: %s, steps: %s\n" % \ 
    399                (str(self.qmin),str(self.qmax), str(self.npts)) 
     403               (str(self.qmin), str(self.qmax), str(self.npts)) 
    400404        rep += "Dispersion selection : %s\n" % str(self.disp_box) 
    401405        rep += "Smearing enable : %s\n" % str(self.enable_smearer) 
     
    413417 
    414418        rep += "2D enable : %s\n" % str(self.enable2D) 
    415         rep += "All parameters checkbox selected: %s\n" % str(self.cb1) 
     419        rep += "All parameters checkbox selected: %s\n" % self.cb1 
    416420        rep += "Value of Chisqr : %s\n" % str(self.tcChi) 
    417         rep += "Smear object : %s\n" % str(self.smearer) 
    418         rep += "Smear type : %s\n" % str(self.smear_type) 
     421        rep += "Smear object : %s\n" % self.smearer 
     422        rep += "Smear type : %s\n" % self.smear_type 
    419423        rep += "dq_l  : %s\n" % self.dq_l 
    420424        rep += "dq_r  : %s\n" % self.dq_r 
     
    478482                value = content[1] 
    479483            except Exception: 
    480                 msg = "Report string expected 'name: value' but got %r"%line 
     484                msg = "Report string expected 'name: value' but got %r" % line 
    481485                logging.error(msg) 
    482486            if name.count("State created"): 
     
    493497            if name == "value": 
    494498                param_string += value + ',' 
     499            fixed_parameter = False 
    495500            if name == "selected": 
    496501                if value == u' False': 
    497502                    fixed_parameter = True 
    498                 else: 
    499                     fixed_parameter = False 
    500503            if name == "error value": 
    501504                if fixed_parameter: 
     
    617620        dialog.Show() 
    618621 
    619     def _toXML_helper(self, thelist, element, newdoc): 
     622    def _to_xml_helper(self, thelist, element, newdoc): 
    620623        """ 
    621624        Helper method to create xml file for saving state 
     
    635638            element.appendChild(sub_element) 
    636639 
    637     def toXML(self, file="fitting_state.fitv", doc=None, 
    638               entry_node=None, batch_fit_state=None): 
     640    def to_xml(self, file="fitting_state.fitv", doc=None, 
     641               entry_node=None, batch_fit_state=None): 
    639642        """ 
    640643        Writes the state of the fit panel to file, as XML. 
     
    648651        :param entry_node: XML node within the XML document at which we 
    649652                           will append the data [optional] 
     653        :param batch_fit_state: simultaneous fit state 
    650654        """ 
    651655        from xml.dom.minidom import getDOMImplementation 
     
    746750        for item in LIST_OF_STATE_PARAMETERS: 
    747751            element = newdoc.createElement(item[0]) 
    748             self._toXML_helper(thelist=getattr(self, item[1]), 
    749                                element=element, newdoc=newdoc) 
     752            self._to_xml_helper(thelist=getattr(self, item[1]), 
     753                                element=element, newdoc=newdoc) 
    750754            inputs.appendChild(element) 
    751755 
     
    765769            for constraint in batch_fit_state.constraints_list: 
    766770                if constraint.model_cbox.GetValue() != "": 
    767                     # model_cbox, param_cbox, egal_txt, constraint, btRemove, sizer 
     771                    # model_cbox, param_cbox, egal_txt, constraint, 
     772                    # btRemove, sizer 
    768773                    doc_cons = newdoc.createElement('constraint') 
    769774                    doc_cons.setAttribute('model_cbox', 
     
    808813            return newdoc 
    809814 
    810     def _fromXML_helper(self, node, list): 
     815    def _from_xml_helper(self, node, list): 
    811816        """ 
    812817        Helper function to write state to xml 
     
    858863                         [maximum_displayed, maximum_value], unit]) 
    859864 
    860     def fromXML(self, file=None, node=None): 
     865    def from_xml(self, file=None, node=None): 
    861866        """ 
    862867        Load fitting state from a file 
     
    887892                    logging.error(msg) 
    888893 
    889             # Parse fitting attributes 
    890             entry = get_content('ns:Attributes', node) 
    891             for item in LIST_OF_DATA_ATTRIBUTES: 
    892                 node = get_content('ns:%s' % item[0], entry) 
    893                 setattr(self, item[0], parse_entry_helper(node, item)) 
    894  
    895894            if entry is not None: 
     895                # Parse fitting attributes 
     896                entry = get_content('ns:Attributes', node) 
     897                for item in LIST_OF_DATA_ATTRIBUTES: 
     898                    node = get_content('ns:%s' % item[0], entry) 
     899                    setattr(self, item[0], parse_entry_helper(node, item)) 
     900 
    896901                for item in LIST_OF_STATE_ATTRIBUTES: 
    897902                    node = get_content('ns:%s' % item[0], entry) 
     
    900905                for item in LIST_OF_STATE_PARAMETERS: 
    901906                    node = get_content("ns:%s" % item[0], entry) 
    902                     self._fromXML_helper(node=node, list=getattr(self, item[1])) 
     907                    self._from_xml_helper(node=node, 
     908                                          list=getattr(self, item[1])) 
    903909 
    904910                # Recover _disp_obj_dict from xml file 
     
    950956        """ 
    951957        images = [] 
    952         # some imports 
    953         import wx 
    954958 
    955959        # Reset memory 
     
    958962 
    959963        # For no figures in the list, prepare empty plot 
    960         if figs == None or len(figs) == 0: 
     964        if figs is None or len(figs) == 0: 
    961965            figs = [None] 
    962966 
     
    965969        self.imgRAM = wx.MemoryFSHandler() 
    966970        for fig in figs: 
    967             if figs != None: 
     971            if fig is not None: 
    968972                ind = figs.index(fig) 
    969973                canvas = canvases[ind] 
    970974 
    971             #store the image in wx.FileSystem Object 
     975            # store the image in wx.FileSystem Object 
    972976            wx.FileSystem.AddHandler(wx.MemoryFSHandler()) 
    973977 
     
    975979            ind = figs.index(fig) 
    976980 
    977             #AddFile, image can be retrieved with 'memory:filename' 
     981            # AddFile, image can be retrieved with 'memory:filename' 
    978982            self.imgRAM.AddFile('img_fit%s.png' % ind, 
    979983                                canvas.bitmap, wx.BITMAP_TYPE_PNG) 
    980984 
    981             #append figs 
     985            # append figs 
    982986            images.append(fig) 
    983987 
     
    989993    Class to load a .fitv fitting file 
    990994    """ 
    991     ## File type 
     995    # File type 
    992996    type_name = "Fitting" 
    993997 
    994     ## Wildcards 
     998    # Wildcards 
    995999    type = ["Fitting files (*.fitv)|*.fitv" 
    9961000            "SASView file (*.svs)|*.svs"] 
    997     ## List of allowed extensions 
     1001    # List of allowed extensions 
    9981002    ext = ['.fitv', '.FITV', '.svs', 'SVS'] 
    9991003 
     
    10091013 
    10101014        """ 
    1011         ## Call back method to be executed after a file is read 
     1015        # Call back method to be executed after a file is read 
    10121016        self.call_back = call_back 
    1013         ## CanSAS format flag 
     1017        # CanSAS format flag 
    10141018        self.cansas = cansas 
    10151019        self.state = None 
     
    10271031 
    10281032        """ 
    1029         if self.cansas == True: 
     1033        if self.cansas: 
    10301034            return self._read_cansas(path) 
    10311035 
     
    10611065        for item in datainfo.run: 
    10621066            runname = {} 
    1063             if datainfo.run_name.has_key(item) and \ 
     1067            if item in datainfo.run_name and \ 
    10641068                            len(str(datainfo.run_name[item])) > 1: 
    10651069                runname = {'name': datainfo.run_name[item]} 
     
    10761080            root_node = doc.createElement(item[0]) 
    10771081            new_node.appendChild(root_node) 
    1078             temp_list = None 
    10791082            temp_list = getattr(datainfo, item[1]) 
    10801083 
     
    11131116                                       datainfo.sample.position.z, 
    11141117                                       {"unit": datainfo.sample.position_unit}) 
    1115         if written == True: 
     1118        if written: 
    11161119            sample.appendChild(pos) 
    11171120 
     
    11211124        written = written | write_node(doc, ori, "pitch", 
    11221125                                       datainfo.sample.orientation.y, 
    1123                                        {"unit": datainfo.sample.orientation_unit}) 
     1126                                       {"unit": 
     1127                                            datainfo.sample.orientation_unit}) 
    11241128        written = written | write_node(doc, ori, "yaw", 
    11251129                                       datainfo.sample.orientation.z, 
    1126                                        {"unit": datainfo.sample.orientation_unit}) 
    1127         if written == True: 
     1130                                       {"unit": 
     1131                                            datainfo.sample.orientation_unit}) 
     1132        if written: 
    11281133            sample.appendChild(ori) 
    11291134 
     
    11531158                                       datainfo.source.beam_size.z, 
    11541159                                       {"unit": datainfo.source.beam_size_unit}) 
    1155         if written == True: 
     1160        if written: 
    11561161            source.appendChild(size) 
    11571162 
     
    11981203                written = written | write_node(doc, size, "z", apert.size.z, 
    11991204                                               {"unit": apert.size_unit}) 
    1200                 if written == True: 
     1205                if written: 
    12011206                    ap.appendChild(size) 
    12021207 
     
    12101215                                           item.slit_length, 
    12111216                                           {"unit": item.slit_length_unit}) 
    1212             if written == True: 
     1217            if written: 
    12131218                instr.appendChild(det) 
    12141219 
     
    12201225            written = written | write_node(doc, off, "z", item.offset.z, 
    12211226                                           {"unit": item.offset_unit}) 
    1222             if written == True: 
     1227            if written: 
    12231228                det.appendChild(off) 
    12241229 
     
    12321237                                           item.beam_center.z, 
    12331238                                           {"unit": item.beam_center_unit}) 
    1234             if written == True: 
     1239            if written: 
    12351240                det.appendChild(center) 
    12361241 
     
    12421247            written = written | write_node(doc, pix, "z", item.pixel_size.z, 
    12431248                                           {"unit": item.pixel_size_unit}) 
    1244             if written == True: 
     1249            if written: 
    12451250                det.appendChild(pix) 
    12461251 
     
    12531258            written = written | write_node(doc, ori, "yaw", item.orientation.z, 
    12541259                                           {"unit": item.orientation_unit}) 
    1255             if written == True: 
     1260            if written: 
    12561261                det.appendChild(ori) 
    12571262 
     
    12901295                # Create an empty state 
    12911296                state = PageState() 
    1292                 state.fromXML(node=nodes[0]) 
     1297                state.from_xml(node=nodes[0]) 
    12931298 
    12941299        except: 
     
    13141319                simfitstate_0 = simfitstate[0] 
    13151320                all = simfitstate_0.xpath('ns:select_all', 
    1316                                         namespaces={'ns': CANSAS_NS}) 
     1321                                          namespaces={'ns': CANSAS_NS}) 
    13171322                atts = all[0].attrib 
    13181323                checked = atts.get('checked') 
    13191324                sim_fit_state.select_all = bool(checked) 
    13201325                model_list = simfitstate_0.xpath('ns:model_list', 
    1321                                                namespaces={'ns': CANSAS_NS}) 
     1326                                                 namespaces={'ns': CANSAS_NS}) 
    13221327                model_list_items = model_list[0].xpath('ns:model_list_item', 
    1323                                                    namespaces={'ns': CANSAS_NS}) 
     1328                                                       namespaces={'ns': 
     1329                                                                    CANSAS_NS}) 
    13241330                for model in model_list_items: 
    13251331                    attrs = model.attrib 
     
    13681374            return return_value, _ 
    13691375 
    1370         #Parse 2D 
     1376        # Parse 2D 
    13711377        data_info = Data2D() 
    13721378 
     
    15901596        for entry in nodes: 
    15911597            for item in LIST_OF_DATA_2D_ATTR: 
    1592                 #get node 
     1598                # get node 
    15931599                node = get_content('ns:%s' % item[0], entry) 
    15941600                setattr(data_info, item[1], parse_entry_helper(node, item)) 
     
    16331639                    entry_list = root.xpath('ns:SASentry', 
    16341640                                            namespaces={'ns': CANSAS_NS}) 
    1635                     name_map = {} 
    16361641                    for entry in entry_list: 
    16371642                        try: 
     
    16791684                        state.data.is_data = state.is_data 
    16801685                    if output[ind].run_name is not None\ 
    1681                         and len(output[ind].run_name) != 0: 
     1686                         and len(output[ind].run_name) != 0: 
    16821687                        if isinstance(output[ind].run_name, dict): 
    16831688                            name = output[ind].run_name.keys()[0] 
     
    17151720            # Write the XML document 
    17161721        else: 
    1717             doc = fitstate.toXML(file=filename) 
     1722            doc = fitstate.to_xml(file=filename) 
    17181723 
    17191724        # Save the document no matter the type 
     
    17491754 
    17501755        if state is not None: 
    1751             doc = state.toXML(doc=doc, file=data.filename, entry_node=sasentry, 
    1752                               batch_fit_state=self.batchfit_params) 
     1756            doc = state.to_xml(doc=doc, file=data.filename, entry_node=sasentry, 
     1757                               batch_fit_state=self.batchfit_params) 
    17531758 
    17541759        return doc 
  • src/sas/sasgui/perspectives/invariant/media/invariant_help.rst

    rb64b87c r484141c  
    116116Academic Press, New York, 1982 
    117117 
    118 http://physchem.kfunigraz.ac.at/sm/ 
     118http://web.archive.org/web/20110824105537/http://physchem.kfunigraz.ac.at/sm/Service/Glatter_Kratky_SAXS_1982.zip 
    119119 
    120120.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
  • src/sas/sasgui/perspectives/pr/pr.py

    rc10d9d6c ra69a967  
    12761276                    wx.PostEvent(self.parent, StatusEvent(status=msg, info='error')) 
    12771277                    return 
    1278                 msg += "Prview does not allow multiple data!\n" 
     1278                msg = "Prview does not allow multiple data!\n" 
    12791279                msg += "Please select one.\n" 
    12801280                if len(data_list) > 1: 
Note: See TracChangeset for help on using the changeset viewer.