Changeset d26f025 in sasview for src/sas/sasgui/plottools


Ignore:
Timestamp:
Apr 9, 2017 8:48:35 AM (8 years ago)
Author:
ajj
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
b6b81a3, 7b15990, 24b3821, cbb9551, 8d891d1, ecdd132, 115eb7e, 2e17ee4, 0657b10
Parents:
ea45bfe (diff), 4342fed0 (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' of https://www.github.com/sasview/sasview

Location:
src/sas/sasgui/plottools
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/plottools/PlotPanel.py

    r959eb01 r7432acb  
    154154        self.selectedText = None 
    155155        #User scale 
    156         if xtransform != None: 
     156        if xtransform is not None: 
    157157            self.xLabel = xtransform 
    158158        else: 
    159159            self.xLabel = "log10(x)" 
    160         if ytransform != None: 
     160        if ytransform is not None: 
    161161            self.yLabel = ytransform 
    162162        else: 
     
    360360                    return 
    361361 
    362             if ax != None: 
     362            if ax is not None: 
    363363                self.xInit, self.yInit = event.xdata, event.ydata 
    364364                try: 
     
    392392        Set legend alpha 
    393393        """ 
    394         if self.legend != None: 
     394        if self.legend is not None: 
    395395            self.legend.legendPatch.set_alpha(alpha) 
    396396 
     
    418418        """ 
    419419        ax = event.inaxes 
    420         if ax == None: 
     420        if ax is None: 
    421421            return 
    422422        # Event occurred inside a plotting area 
     
    461461            # User has clicked on text and is dragging 
    462462            ax = event.inaxes 
    463             if ax != None: 
     463            if ax is not None: 
    464464                # Only move text if mouse is within axes 
    465465                self.selectedText.set_position((event.xdata, event.ydata)) 
     
    476476        if self.leftdown == True and self.mousemotion == True: 
    477477            ax = event.inaxes 
    478             if ax != None:  # the dragging is perform inside the figure 
     478            if ax is not None:  # the dragging is perform inside the figure 
    479479                self.xFinal, self.yFinal = event.xdata, event.ydata 
    480480                # Check whether this is the first point 
    481                 if self.xInit == None: 
     481                if self.xInit is None: 
    482482                    self.xInit = self.xFinal 
    483483                    self.yInit = self.yFinal 
     
    576576        step = event.step 
    577577 
    578         if ax != None: 
     578        if ax is not None: 
    579579            # Event occurred inside a plotting area 
    580580            lo, hi = ax.get_xlim() 
     
    935935        # reset postion 
    936936        self.position = None 
    937         if self.graph.selected_plottable != None: 
     937        if self.graph.selected_plottable is not None: 
    938938            self.graph.selected_plottable = None 
    939939 
     
    959959                                              prop=FontProperties(size=10), 
    960960                                              loc=self.legendLoc) 
    961             if self.legend != None: 
     961            if self.legend is not None: 
    962962                self.legend.set_picker(self.legend_picker) 
    963963                self.legend.set_axes(self.subplot) 
     
    989989                                          prop=FontProperties(size=10), 
    990990                                          loc=self.legendLoc) 
    991         if self.legend != None: 
     991        if self.legend is not None: 
    992992            self.legend.set_picker(self.legend_picker) 
    993993            self.legend.set_axes(self.subplot) 
     
    10101010        pos_x = 0 
    10111011        pos_y = 0 
    1012         if self.position != None: 
     1012        if self.position is not None: 
    10131013            pos_x, pos_y = self.position 
    10141014        else: 
     
    10351035                    self.subplot.figure.canvas.draw_idle() 
    10361036            except: 
    1037                 if self.parent != None: 
     1037                if self.parent is not None: 
    10381038                    msg = "Add Text: Error. Check your property values..." 
    10391039                    wx.PostEvent(self.parent, StatusEvent(status=msg)) 
     
    10691069            self.xaxis_tick = xaxis_font 
    10701070 
    1071         if self.data != None: 
     1071        if self.data is not None: 
    10721072            # 2D 
    10731073            self.xaxis(self.xaxis_label, self.xaxis_unit, \ 
     
    11161116            self.yaxis_tick = yaxis_font 
    11171117 
    1118         if self.data != None: 
     1118        if self.data is not None: 
    11191119            # 2D 
    11201120            self.yaxis(self.yaxis_label, self.yaxis_unit, \ 
     
    11551155                label_temp = textdial.getText() 
    11561156                if label_temp.count("\%s" % "\\") > 0: 
    1157                     if self.parent != None: 
     1157                    if self.parent is not None: 
    11581158                        msg = "Add Label: Error. Can not use double '\\' " 
    11591159                        msg += "characters..." 
     
    11621162                    label = label_temp 
    11631163            except: 
    1164                 if self.parent != None: 
     1164                if self.parent is not None: 
    11651165                    msg = "Add Label: Error. Check your property values..." 
    11661166                    wx.PostEvent(self.parent, StatusEvent(status=msg)) 
     
    11801180        num_text = len(self.textList) 
    11811181        if num_text < 1: 
    1182             if self.parent != None: 
     1182            if self.parent is not None: 
    11831183                msg = "Remove Text: Nothing to remove.  " 
    11841184                wx.PostEvent(self.parent, StatusEvent(status=msg)) 
     
    11901190            text_remove = txt.get_text() 
    11911191            txt.remove() 
    1192             if self.parent != None: 
     1192            if self.parent is not None: 
    11931193                msg = "Removed Text: '%s'. " % text_remove 
    11941194                wx.PostEvent(self.parent, StatusEvent(status=msg)) 
    11951195        except: 
    1196             if self.parent != None: 
     1196            if self.parent is not None: 
    11971197                msg = "Remove Text: Error occurred. " 
    11981198                wx.PostEvent(self.parent, StatusEvent(status=msg)) 
     
    12501250                                        prop=FontProperties(size=10), 
    12511251                                        loc=self.legendLoc) 
    1252                 if self.legend != None: 
     1252                if self.legend is not None: 
    12531253                    self.legend.set_picker(self.legend_picker) 
    12541254                    self.legend.set_axes(self.subplot) 
     
    12791279        if font: 
    12801280            self.subplot.set_xlabel(label, fontproperties=font, color=color) 
    1281             if t_font != None: 
     1281            if t_font is not None: 
    12821282                for tick in self.subplot.xaxis.get_major_ticks(): 
    12831283                    tick.label.set_fontproperties(t_font) 
     
    13001300        if font: 
    13011301            self.subplot.set_ylabel(label, fontproperties=font, color=color) 
    1302             if t_font != None: 
     1302            if t_font is not None: 
    13031303                for tick_label in self.subplot.get_yticklabels(): 
    13041304                    tick_label.set_fontproperties(t_font) 
     
    13271327        from plottable_interactor import PointInteractor 
    13281328        p = PointInteractor(self, self.subplot, zorder=zorder, id=id) 
    1329         if p.markersize != None: 
     1329        if p.markersize is not None: 
    13301330            markersize = p.markersize 
    13311331        p.points(x, y, dx=dx, dy=dy, color=color, symbol=symbol, zorder=zorder, 
     
    13631363 
    13641364        # Convert tuple (lo,hi) to array [(x-lo),(hi-x)] 
    1365         if dx != None and type(dx) == type(()): 
     1365        if dx is not None and type(dx) == type(()): 
    13661366            dx = nx.vstack((x - dx[0], dx[1] - x)).transpose() 
    1367         if dy != None and type(dy) == type(()): 
     1367        if dy is not None and type(dy) == type(()): 
    13681368            dy = nx.vstack((y - dy[0], dy[1] - y)).transpose() 
    1369         if dx == None and dy == None: 
     1369        if dx is None and dy is None: 
    13701370            self.subplot.plot(x, y, color=self._color(color), 
    13711371                              marker=self._symbol(symbol), 
     
    14431443        c = self._color(color) 
    14441444        # If we don't have any data, skip. 
    1445         if self.data == None: 
     1445        if self.data is None: 
    14461446            return 
    14471447        if self.data.ndim == 1: 
     
    15191519            self.subplot.set_axis_off() 
    15201520 
    1521         if cbax == None: 
     1521        if cbax is None: 
    15221522            ax.set_frame_on(False) 
    15231523            cb = self.subplot.figure.colorbar(im, shrink=0.8, aspect=20) 
     
    15411541        """ 
    15421542        # No qx or qy given in a vector format 
    1543         if self.qx_data == None or self.qy_data == None \ 
     1543        if self.qx_data is None or self.qy_data is None \ 
    15441544                or self.qx_data.ndim != 1 or self.qy_data.ndim != 1: 
    15451545            # do we need deepcopy here? 
     
    16011601        """ 
    16021602        # No qx or qy given in a vector format 
    1603         if self.qx_data == None or self.qy_data == None \ 
     1603        if self.qx_data is None or self.qy_data is None \ 
    16041604                or self.qx_data.ndim != 1 or self.qy_data.ndim != 1: 
    16051605            # do we need deepcopy here? 
     
    16521652        """ 
    16531653        # No image matrix given 
    1654         if image == None or np.ndim(image) != 2 \ 
     1654        if image is None or np.ndim(image) != 2 \ 
    16551655                or np.isfinite(image).all() \ 
    1656                 or weights == None: 
     1656                or weights is None: 
    16571657            return image 
    16581658        # Get bin size in y and x directions 
     
    17721772            # control axis labels from the panel itself 
    17731773            yname, yunits = item.get_yaxis() 
    1774             if self.yaxis_label != None: 
     1774            if self.yaxis_label is not None: 
    17751775                yname = self.yaxis_label 
    17761776                yunits = self.yaxis_unit 
     
    17791779                self.yaxis_unit = yunits 
    17801780            xname, xunits = item.get_xaxis() 
    1781             if self.xaxis_label != None: 
     1781            if self.xaxis_label is not None: 
    17821782                xname = self.xaxis_label 
    17831783                xunits = self.xaxis_unit 
     
    19401940        """ 
    19411941        """ 
    1942         if self.parent == None: 
     1942        if self.parent is None: 
    19431943            return 
    19441944        # get current caption 
  • src/sas/sasgui/plottools/TextDialog.py

    r959eb01 r7432acb  
    4141        style_box = wx.BoxSizer(wx.HORIZONTAL) 
    4242        # tcA 
    43         if unit != None: 
     43        if unit is not None: 
    4444            styles = wx.TAB_TRAVERSAL 
    4545            height = -1 
     
    130130                       0, wx.TOP, 5) 
    131131        family_box.Add(self.font_size, 0, 0) 
    132         if unit_box != None: 
     132        if unit_box is not None: 
    133133            family_box.Add((_BOX_WIDTH / 2, -1)) 
    134134            family_box.Add(tick_label_text, 0, 0) 
     
    159159        text_box.Add(self.text_string) 
    160160        vbox.Add(text_box, 0, wx.EXPAND, 15) 
    161         if unit_box != None: 
     161        if unit_box is not None: 
    162162            unit_box.Add(unit_text, 0, 0) 
    163163            unit_box.Add(self.unit_ctrl, 0, 0) 
  • src/sas/sasgui/plottools/arrow3d.py

    r959eb01 r7432acb  
    2929        self.base = base 
    3030 
    31         if base != None: 
     31        if base is not None: 
    3232            # To turn the updating off during dragging 
    3333            base.canvas.mpl_connect('button_press_event', self.on_left_down) 
  • src/sas/sasgui/plottools/canvas.py

    r463e7ffc r7432acb  
    153153        """ 
    154154        self.panel.subplot.grid(self.panel.grid_on) 
    155         if self.panel.legend != None and self.panel.legend_pos_loc: 
     155        if self.panel.legend is not None and self.panel.legend_pos_loc: 
    156156            self.panel.legend._loc = self.panel.legend_pos_loc 
    157157        self.idletimer.Restart(5, *args, **kwargs)  # Delay by 5 ms 
  • src/sas/sasgui/plottools/fitDialog.py

    r959eb01 r7432acb  
    9595 
    9696        # Set default value of parameter in the dialog panel 
    97         if self.Avalue == None: 
     97        if self.Avalue is None: 
    9898            self.tcA.SetValue(format_number(self.default_A)) 
    9999        else: 
    100100            self.tcA.SetLabel(format_number(self.Avalue)) 
    101         if self.Bvalue == None: 
     101        if self.Bvalue is None: 
    102102            self.tcB.SetValue(format_number(self.default_B)) 
    103103        else: 
    104104            self.tcB.SetLabel(format_number(self.Bvalue)) 
    105         if self.ErrAvalue == None: 
     105        if self.ErrAvalue is None: 
    106106            self.tcErrA.SetLabel(format_number(0.0)) 
    107107        else: 
    108108            self.tcErrA.SetLabel(format_number(self.ErrAvalue)) 
    109         if self.ErrBvalue == None: 
     109        if self.ErrBvalue is None: 
    110110            self.tcErrB.SetLabel(format_number(0.0)) 
    111111        else: 
    112112            self.tcErrB.SetLabel(format_number(self.ErrBvalue)) 
    113         if self.Chivalue == None: 
     113        if self.Chivalue is None: 
    114114            self.tcChi.SetLabel(format_number(0.0)) 
    115115        else: 
     
    502502 
    503503                # Check that cov and out are iterable before displaying them 
    504                 if cov == None: 
     504                if cov is None: 
    505505                    errA = 0.0 
    506506                    errB = 0.0 
     
    508508                    errA = math.sqrt(cov[0][0]) 
    509509                    errB = math.sqrt(cov[1][1]) 
    510                 if out == None: 
     510                if out is None: 
    511511                    cstA = 0.0 
    512512                    cstB = 0.0 
     
    579579                    self.I0_tctr.SetValue(format_number(val)) 
    580580            if self.Rgerr_tctr.IsShown(): 
    581                 if rg != None and rg != 0: 
     581                if rg is not None and rg != 0: 
    582582                    value = format_number(3 * float(errA) / (2 * rg)) 
    583583                else: 
     
    593593                self.Diameter_tctr.SetValue(value) 
    594594            if self.Diametererr_tctr.IsShown(): 
    595                 if rg != None and rg != 0: 
     595                if rg is not None and rg != 0: 
    596596                    value = format_number(8 * float(errA) / _diam) 
    597597                else: 
  • src/sas/sasgui/plottools/fittings.py

    r959eb01 rac07a3a  
    2525        self.model = model 
    2626        self.name = name 
    27         if not value == None: 
     27        if value is not None: 
    2828            self.model.setParam(self.name, value) 
    2929 
  • src/sas/sasgui/plottools/plottable_interactor.py

    r959eb01 r45dffa69  
    5050            l_width = markersize * 0.4 
    5151            return self.step(x=x, y=y, color=color, label=label, width=l_width) 
    52         if not self.marker == None: 
    53             self.base.connect.clear([self.marker]) 
    54         self.color = self._color(color) 
    55         if self.markersize != None: 
     52        if self.marker is not None: 
     53            self.base.connect.clear([self.marker]) 
     54        self.color = self._color(color) 
     55        if self.markersize is not None: 
    5656            markersize = self.markersize 
    5757        # Convert tuple (lo,hi) to array [(x-lo),(hi-x)] 
    58         if dx != None and type(dx) == type(()): 
     58        if dx is not None and type(dx) == type(()): 
    5959            dx = nx.vstack((x - dx[0], dx[1] - x)).transpose() 
    60         if dy != None and type(dy) == type(()): 
     60        if dy is not None and type(dy) == type(()): 
    6161            dy = nx.vstack((y - dy[0], dy[1] - y)).transpose() 
    6262 
    63         if dx == None and dy == None: 
     63        if dx is None and dy is None: 
    6464            # zorder = 1 
    6565            self.marker = self.axes.plot(x, y, color=self.color, 
     
    100100        """ 
    101101        """ 
    102         if not self.marker == None: 
     102        if self.marker is not None: 
    103103            self.base.connect.clear([self.marker]) 
    104104        self.color = self._color(color) 
     
    115115        """ 
    116116        """ 
    117         if not self.marker == None: 
     117        if self.marker is not None: 
    118118            self.base.connect.clear([self.marker]) 
    119119        self.color = self._color(color) 
     
    133133        """ 
    134134        """ 
    135         if not self.marker == None: 
     135        if self.marker is not None: 
    136136            self.base.connect.clear([self.marker]) 
    137137        self.color = self._color(color) 
  • src/sas/sasgui/plottools/plottables.py

    r9c0f3c17 r45dffa69  
    229229            if p.hidden == True: 
    230230                continue 
    231             if not p.x == None: 
     231            if p.x is not None: 
    232232                for x_i in p.x: 
    233                     if min_value == None or x_i < min_value: 
     233                    if min_value is None or x_i < min_value: 
    234234                        min_value = x_i 
    235                     if max_value == None or x_i > max_value: 
     235                    if max_value is None or x_i > max_value: 
    236236                        max_value = x_i 
    237237        return min_value, max_value 
     
    562562        Returns True if there is no data stored in the plottable 
    563563        """ 
    564         if not self.x == None and len(self.x) == 0 \ 
    565             and not self.y == None and len(self.y) == 0: 
     564        if (self.x is not None and len(self.x) == 0 
     565            and self.y is not None and len(self.y) == 0): 
    566566            return True 
    567567        return False 
     
    679679        # Sanity check 
    680680        # Do the transofrmation only when x and y are empty 
    681         has_err_x = not (dx == None or len(dx) == 0) 
    682         has_err_y = not (dy == None or len(dy) == 0) 
    683  
    684         if(x != None) and (y != None): 
    685             if not dx == None and not len(dx) == 0 and not len(x) == len(dx): 
     681        has_err_x = not (dx is None or len(dx) == 0) 
     682        has_err_y = not (dy is None or len(dy) == 0) 
     683 
     684        if(x is not None) and (y is not None): 
     685            if dx is not None and not len(dx) == 0 and not len(x) == len(dx): 
    686686                msg = "Plottable.View: Given x and dx are not" 
    687687                msg += " of the same length" 
     
    693693                raise ValueError, msg 
    694694 
    695             if not dy == None and not len(dy) == 0 and not len(y) == len(dy): 
     695            if dy is not None and not len(dy) == 0 and not len(y) == len(dy): 
    696696                msg = "Plottable.View: Given y and dy are not of the same " 
    697697                msg += "length: len(y)=%s, len(dy)=%s" % (len(y), len(dy)) 
     
    797797        tempy = [] 
    798798        tempdy = [] 
    799         if self.dx == None: 
     799        if self.dx is None: 
    800800            self.dx = np.zeros(len(self.x)) 
    801         if self.dy == None: 
     801        if self.dy is None: 
    802802            self.dy = np.zeros(len(self.y)) 
    803803        if self.xLabel == "log10(x)": 
     
    827827        tempy = [] 
    828828        tempdy = [] 
    829         if self.dx == None: 
     829        if self.dx is None: 
    830830            self.dx = np.zeros(len(self.x)) 
    831         if self.dy == None: 
     831        if self.dy is None: 
    832832            self.dy = np.zeros(len(self.y)) 
    833833        if self.yLabel == "log10(y)": 
     
    860860        tempy = [] 
    861861        tempdy = [] 
    862         if self.dx == None: 
     862        if self.dx is None: 
    863863            self.dx = np.zeros(len(self.x)) 
    864         if self.dy == None: 
     864        if self.dy is None: 
    865865            self.dy = np.zeros(len(self.y)) 
    866         if xmin != None and xmax != None: 
     866        if xmin is not None and xmax is not None: 
    867867            for i in range(len(self.x)): 
    868868                if self.x[i] >= xmin and self.x[i] <= xmax: 
     
    12061206        """ 
    12071207        """ 
    1208         if  self._chisq == None: 
     1208        if  self._chisq is None: 
    12091209            chisqTxt = r'$\chi^2=$' 
    12101210        else: 
  • src/sas/sasgui/plottools/transform.py

    r959eb01 r7432acb  
    162162 
    163163    """ 
    164     if dx == None: 
     164    if dx is None: 
    165165        dx = 0 
    166166    return dx 
     
    175175 
    176176    """ 
    177     if dx == None: 
     177    if dx is None: 
    178178        dx = 0 
    179179    return dx 
     
    188188 
    189189    """ 
    190     if  dx != None: 
     190    if  dx is not None: 
    191191        err = 2 * x * dx 
    192192        return math.fabs(err) 
     
    204204    """ 
    205205    if x > 0: 
    206         if dx != None: 
     206        if dx is not None: 
    207207            err = dx / (2 * math.sqrt(x)) 
    208208        else: 
     
    222222 
    223223    """ 
    224     if dx != None: 
     224    if dx is not None: 
    225225        err = 4 * math.pow(x, 3) * dx 
    226226        return math.fabs(err) 
     
    238238    """ 
    239239    if x > 0: 
    240         if dx != None: 
     240        if dx is not None: 
    241241            err = dx / (4 * math.pow(x, 3 / 4)) 
    242242        else: 
     
    256256 
    257257    """ 
    258     if dx == None: 
     258    if dx is None: 
    259259        dx = 0 
    260260 
     
    280280 
    281281    """ 
    282     if dx == None: 
     282    if dx is None: 
    283283        dx = 0 
    284284 
     
    294294    """ 
    295295    """ 
    296     if dx == None: 
    297         dx = 0 
    298     if dy == None: 
     296    if dx is None: 
     297        dx = 0 
     298    if dy is None: 
    299299        dy = 0 
    300300    err = math.sqrt((2 * x * y * dx) ** 2 + ((x ** 2) * dy) ** 2) 
     
    314314        raise ValueError, msg 
    315315    if x != 0 and y != 0: 
    316         if dx == None: 
     316        if dx is None: 
    317317            dx = 0 
    318         if dy == None: 
     318        if dy is None: 
    319319            dy = 0 
    320320        err = (dx / x) ** 2 + (dy / y) ** 2 
     
    337337        raise ValueError, msg 
    338338    if x > 0 and y > 0: 
    339         if dx == None: 
     339        if dx is None: 
    340340            dx = 0 
    341         if dy == None: 
     341        if dy is None: 
    342342            dy = 0 
    343343        err = (2.0 * dx / x) ** 2 + (dy / y) ** 2 
     
    353353    """ 
    354354    if x != 0: 
    355         if dx == None: 
     355        if dx is None: 
    356356            dx = 0 
    357357        err = dx / x ** 2 
     
    367367    """ 
    368368    if x > 0: 
    369         if dx == None: 
     369        if dx is None: 
    370370            dx = 0 
    371371        err = -1 / 2 * math.pow(x, -3.0 / 2.0) * dx 
     
    388388        msg += " that are consistent with zero." 
    389389        raise ValueError, msg 
    390     if dx == None: 
    391         dx = 0 
    392     if dy == None: 
     390    if dx is None: 
     391        dx = 0 
     392    if dy is None: 
    393393        dy = 0 
    394394    err = math.sqrt((4.0 * dx / x) ** 2 + (dy / y) ** 2) 
     
    406406    # within errors 
    407407 
    408     if dx == None: 
    409         dx = 0 
    410     if dy == None: 
     408    if dx is None: 
     409        dx = 0 
     410    if dy is None: 
    411411        dy = 0 
    412412    err = math.sqrt((dy * pow(x, 4)) ** 2 + (4 * y * dx * math.pow(x, 3)) ** 2) 
Note: See TracChangeset for help on using the changeset viewer.