Changeset ca4f40d in sasview


Ignore:
Timestamp:
Jan 19, 2019 7:57:07 PM (5 years ago)
Author:
butler
Branches:
master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249
Children:
1342f6a
Parents:
722c425
Message:

replace checking for class name with isinstance throughout fitpage.py

File:
1 edited

Legend:

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

    r722c425 rca4f40d  
    1818 
    1919from sas.sascalc.fit.qsmearing import smear_selection 
     20from sas.sascalc.dataloader.data_info import Data1D, Data2D 
    2021 
    2122from sas.sasgui.guiframe.events import StatusEvent, NewPlotEvent, \ 
     
    187188        :return: True or False 
    188189        """ 
    189         if self.data.__class__.__name__ == "Data2D" or \ 
    190                         self.enable2D: 
     190        if isinstance(self.data, Data2D) or self.enable2D: 
    191191            return True 
    192192        return False 
     
    202202 
    203203        # Check if data is 2D 
    204         if self.data.__class__.__name__ == "Data2D" or \ 
    205                         self.enable2D: 
     204        if isinstance(self.data, Data2D) or self.enable2D: 
    206205            is_2d_data = True 
    207206 
     
    518517 
    519518        # check if it is 2D data 
    520         if self.data.__class__.__name__ == "Data2D" or self.enable2D: 
     519        if isinstance(self.data, Data2D) or self.enable2D: 
    521520            is_2d_data = True 
    522521 
     
    821820                        self.sizer4_4.Add(cb, (iy, ix), (1, 1), 
    822821                                wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 5) 
    823                         if self.data.__class__.__name__ == "Data2D" or \ 
    824                                     self.enable2D: 
     822                        if isinstance(self.data, Data2D) or self.enable2D: 
    825823                            cb.Show(True) 
    826824                        elif cb.IsShown(): 
     
    834832                        ctl1.SetToolTipString(poly_tip) 
    835833                        ctl1.SetValue(str(format_number(value, True))) 
    836                         if self.data.__class__.__name__ == "Data2D" or \ 
    837                                     self.enable2D: 
     834                        if isinstance(self.data, Data2D) or self.enable2D: 
    838835                            if first_orient: 
    839836                                values.SetLabel('PD[ratio], Sig[deg]') 
     
    869866 
    870867                        ctl2.Hide() 
    871                         if self.data.__class__.__name__ == "Data2D" or \ 
    872                                 self.enable2D: 
     868                        if isinstance(self.data, Data2D) or self.enable2D: 
    873869                            if self.is_mac: 
    874870                                text2.Show(True) 
     
    895891                        ctl4.Hide() 
    896892 
    897                         if self.data.__class__.__name__ == "Data2D" or \ 
    898                                 self.enable2D: 
     893                        if isinstance(self.data, Data2D) or self.enable2D: 
    899894                            ctl3.Show(True) 
    900895                            ctl4.Show(True) 
     
    908903 
    909904                        Tctl.SetValue(str(format_number(value))) 
    910                         if self.data.__class__.__name__ == "Data2D" or \ 
    911                                 self.enable2D: 
     905                        if isinstance(self.data, Data2D) or self.enable2D: 
    912906                            Tctl.Show(True) 
    913907                        else: 
     
    928922 
    929923                        Tct2.SetValue(str(format_number(value))) 
    930                         if self.data.__class__.__name__ == "Data2D" or \ 
    931                                 self.enable2D: 
     924                        if isinstance(self.data, Data2D) or self.enable2D: 
    932925                            Tct2.Show(True) 
    933926                        else: 
     
    956949                                            text2, ctl2, ctl3, ctl4, disp_box]) 
    957950 
    958                 if self.data.__class__.__name__ == "Data2D" or \ 
    959                                 self.enable2D: 
     951                if isinstance(self.data, Data2D) or self.enable2D: 
    960952                    disp_box.Show(True) 
    961953                else: 
     
    13421334                        flag1 = self.update_pinhole_smear() 
    13431335                        flag = flag or flag1 
    1344                 elif self.data.__class__.__name__ != "Data2D" and \ 
    1345                         not self.enable2D: 
     1336                elif not isinstance(self.data, Data2D) and not self.enable2D: 
    13461337                    enable_smearer = not self.disable_smearer.GetValue() 
    13471338                    self._manager.set_smearer(smearer=temp_smearer, 
     
    14161407        if event is not None: 
    14171408            event.Skip() 
    1418         if self.data.__class__.__name__ == "Data2D": 
     1409        if isinstance(self.data, Data2D): 
    14191410            return 
    14201411        is_click = event.LeftDown() 
     
    14341425        if event is not None: 
    14351426            event.Skip() 
    1436         if self.data.__class__.__name__ == "Data2D": 
     1427        if isinstance(self.data, Data2D): 
    14371428            return 
    14381429        act_ctrl = event.GetEventObject() 
     
    14501441        """ 
    14511442        event.Skip() 
    1452         if self.data.__class__.__name__ == "Data2D": 
     1443        if isinstance(self.data, Data2D): 
    14531444            return 
    14541445        ctrl = event.GetEventObject() 
     
    15111502            # Check if # of points for theory model are valid(>0). 
    15121503            # check for 2d 
    1513             if self.data.__class__.__name__ == "Data2D" or \ 
    1514                     self.enable2D: 
     1504            if isinstance(self.data, Data2D) or self.enable2D: 
    15151505                # set mask 
    15161506                radius = np.sqrt(self.data.qx_data * self.data.qx_data + 
     
    15641554                if item[0].IsShown(): 
    15651555                    # Skip the angle parameters if 1D data 
    1566                     if self.data.__class__.__name__ != "Data2D" and \ 
    1567                             not self.enable2D: 
     1556                    if not isinstance(self.data, Data2D) and not self.enable2D: 
    15681557                        if item in self.orientation_params: 
    15691558                            continue 
     
    15831572                if item[0].IsShown(): 
    15841573                    # Skip the angle parameters if 1D data 
    1585                     if self.data.__class__.__name__ != "Data2D" and \ 
    1586                             not self.enable2D: 
     1574                    if not isinstance(self.data, Data2D) and not self.enable2D: 
    15871575                        if item in self.orientation_params: 
    15881576                            continue 
     
    16341622        #Otherwise no smearing can be applied using smear from data (a Gaussian 
    16351623        #width of zero will cause a divide by zero error) 
    1636         if self.data.__class__.__name__ == "Data2D": 
     1624        if isinstance(self.data, Data2D): 
    16371625            if data.dqx_data is not None and data.dqy_data is not None \ 
    16381626              and data.dqx_data.all()and data.dqy_data.all(): 
     
    16541642        #Otherwise no smearing can be applied using smear from data (a Gaussian 
    16551643        #width of zero will cause a divide by zero error) 
    1656         elif self.data.__class__.__name__ == "Data1D": 
     1644        elif isinstance(self.data, Data1D): 
    16571645            #is it valid 1D pinhole resolution data? 
    16581646            if data.dx is not None and np.all(data.dx): 
     
    19751963            di_flag = False 
    19761964            dq_flag = False 
    1977             if self.data.__class__.__name__ == "Data2D" or \ 
    1978                         self.enable2D: 
     1965            if isinstance(self.data, Data2D) or self.enable2D: 
    19791966                self.slit_smearer.Disable() 
    19801967                self.pinhole_smearer.Enable(True) 
     
    20612048        # update model plot with new data information 
    20622049        if flag: 
    2063             if self.data.__class__.__name__ == "Data2D": 
     2050            if isinstance(self.data, Data2D): 
    20642051                self.enable2D = True 
    20652052                self.model_view.SetLabel("2D Mode") 
     
    21282115        npts2fit = 0 
    21292116        qmin, qmax = self.get_range() 
    2130         if self.data.__class__.__name__ == "Data2D" or \ 
    2131                         self.enable2D: 
     2117        if isinstance(self.data, Data2D) or self.enable2D: 
    21322118            radius = np.sqrt(self.data.qx_data * self.data.qx_data + 
    21332119                                self.data.qy_data * self.data.qy_data) 
     
    25192505            of the values entered for slit smear 
    25202506        """ 
    2521         if self.data.__class__.__name__ == "Data2D" or self.enable2D: 
     2507        if isinstance(self.data, Data2D) or self.enable2D: 
    25222508            return 
    25232509        # make sure once more if it is smearer 
     
    27152701        for item in self.parameters: 
    27162702            # Skip t ifhe angle parameters if 1D data 
    2717             if self.data.__class__.__name__ != "Data2D" and\ 
    2718                         not self.enable2D: 
     2703            if not isinstance(self.data, Data2D) and not self.enable2D: 
    27192704                if item in self.orientation_params: 
    27202705                    continue 
     
    27322717        for item in self.fittable_param: 
    27332718            # Skip t ifhe angle parameters if 1D data 
    2734             if self.data.__class__.__name__ != "Data2D" and\ 
    2735                         not self.enable2D: 
     2719            if not isinstance(self.data, Data2D) and not self.enable2D: 
    27362720                if item in self.orientation_params: 
    27372721                    continue 
     
    27452729 
    27462730        # Calculate num. of angle parameters 
    2747         if self.data.__class__.__name__ == "Data2D" or \ 
    2748                        self.enable2D: 
     2731        if isinstance(self.data, Data2D) or self.enable2D: 
    27492732            len_orient_para = 0 
    27502733        else: 
     
    30393022                if not self._has_magnetic: 
    30403023                    mag_on_button.Show(False) 
    3041                 elif not self.data.__class__.__name__ == "Data2D": 
     3024                elif not isinstance(self.data, Data2D): 
    30423025                    mag_on_button.Show(False) 
    30433026                else: 
     
    30553038                        mag_angle_help_button.Show(False) 
    30563039 
    3057                 if not self.data.__class__.__name__ == "Data2D" and \ 
    3058                         not self.enable2D: 
     3040                if not isinstance(self.data, Data2D) and not self.enable2D: 
    30593041                    orient_angle.Hide() 
    30603042                else: 
     
    30803062                    cb.SetToolTipString("Check mark to fit") 
    30813063                    wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) 
    3082                     if self.data.__class__.__name__ == "Data2D" or \ 
    3083                             self.enable2D: 
     3064                    if isinstance(self.data, Data2D) or self.enable2D: 
    30843065                        cb.Show(True) 
    30853066                    else: 
     
    30963077                                "Hit 'Enter' after typing to update the plot.") 
    30973078                    ctl1.SetValue(format_number(value, True)) 
    3098                     if self.data.__class__.__name__ == "Data2D" or \ 
    3099                             self.enable2D: 
     3079                    if isinstance(self.data, Data2D) or self.enable2D: 
    31003080                        ctl1.Show(True) 
    31013081                    else: 
     
    31373117                    ctl4.Hide() 
    31383118 
    3139                     if self.data.__class__.__name__ == "Data2D" or \ 
    3140                             self.enable2D: 
     3119                    if isinstance(self.data, Data2D) or self.enable2D: 
    31413120                        if self.is_mac: 
    31423121                            text2.Show(True) 
     
    31543133                        units = wx.StaticText(self, -1, "", 
    31553134                                              style=wx.ALIGN_LEFT) 
    3156                     if self.data.__class__.__name__ == "Data2D" or \ 
    3157                             self.enable2D: 
     3135                    if isinstance(self.data, Data2D) or self.enable2D: 
    31583136                        units.Show(True) 
    31593137                    else: 
     
    32343212        """ 
    32353213        # more disables for 2D 
    3236         if self.data.__class__.__name__ == "Data2D" or \ 
    3237                     self.enable2D: 
     3214        if isinstance(self.data, Data2D) or self.enable2D: 
    32383215            self.slit_smearer.Disable() 
    32393216            self.default_mask = copy.deepcopy(self.data.mask) 
     
    32413218                self.pinhole_smearer.Enable(True) 
    32423219 
    3243         elif self.data.__class__.__name__ == "Data1D": 
     3220        elif isinstance(self.data, Data1D): 
    32443221            if self.model is not None: 
    32453222                self.slit_smearer.Enable(True) 
Note: See TracChangeset for help on using the changeset viewer.