Changeset cee5c78 in sasview for src/sas/qtgui/Plotting


Ignore:
Timestamp:
Nov 9, 2017 6:41:55 AM (6 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
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
Children:
7fb471d
Parents:
b3e8629
git-author:
Piotr Rozyczko <rozyczko@…> (10/27/17 01:42:57)
git-committer:
Piotr Rozyczko <rozyczko@…> (11/09/17 06:41:55)
Message:

Converted more syntax not covered by 2to3

Location:
src/sas/qtgui/Plotting
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Plotting/Arrow3D.py

    • Property mode changed from 100755 to 100644
    rb3e8629 rcee5c78  
    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/qtgui/Plotting/Binder.py

    • Property mode changed from 100755 to 100644
    rb3e8629 rcee5c78  
    233233        """ 
    234234        # TODO: sort by zorder of axes then by zorder within axes 
    235         self._artists.sort(cmp=lambda x, y: cmp(y.zorder, x.zorder)) 
     235        #self._artists.sort(cmp=lambda x, y: cmp(y.zorder, x.zorder)) 
     236        #self._artists.sort(cmp=lambda x, y: y.zorder.__gt__(x.zorder)) 
    236237        found = Selection() 
    237238        for artist in self._artists: 
  • src/sas/qtgui/Plotting/ConvertUnits.py

    • Property mode changed from 100755 to 100644
    rb3e8629 rcee5c78  
    44""" 
    55import re 
    6 import string 
    76 
    87def convertUnit(power, unit): 
     
    1110    """ 
    1211    if power != 0: 
    13         if string.find(unit, "^") != -1:  # if the unit contains a powerer ^ 
     12        if unit.find("^") != -1:  # if the unit contains a powerer ^ 
    1413            toks = re.split("\^", unit) 
    15             if string.find(toks[0], "/") != -1 or \ 
    16                 string.find(toks[0], "-") != -1: 
     14            if toks[0].find("/") != -1 or \ 
     15                toks[0].find("-") != -1: 
    1716                if power == 1: 
    1817                    unit = unit 
     
    2019                    unit = "(" + unit + ")" + "^{" + str(power) + "}" 
    2120            else: 
    22                 if string.find(toks[1], "{") != -1:  # if found a { 
     21                if toks[1].find("{") != -1:  # if found a { 
    2322                    find_power_toks = re.split("{", toks[1]) 
    24                     if string.find(find_power_toks[1], "}") != -1:  # found } 
     23                    if find_power_toks[1].find("}") != -1:  # found } 
    2524                        unit_toks = re.split("}", find_power_toks[1]) 
    26                         if string.find(unit_toks[0], ".") != -1: 
     25                        if unit_toks[0].find(".") != -1: 
    2726                            powerer = float(unit_toks[0]) * power 
    28                         elif string.find(unit_toks[0], "/") != -1: 
     27                        elif unit_toks[0].find("/") != -1: 
    2928                            power_toks = re.split("/", unit_toks[0]) 
    3029                            powerer = power * int(power_toks[0])\ 
  • src/sas/qtgui/Plotting/DataTransform.py

    • Property mode changed from 100755 to 100644
    rb3e8629 rcee5c78  
    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) 
  • src/sas/qtgui/Plotting/Fittings.py

    • Property mode changed from 100755 to 100644
    rb3e8629 rcee5c78  
    2222        self.model = model 
    2323        self.name = name 
    24         if not value == None: 
     24        if value is not None: 
    2525            self.model.setParam(self.name, value) 
    2626 
  • src/sas/qtgui/Plotting/PlotUtilities.py

    • Property mode changed from 100755 to 100644
    rb3e8629 rcee5c78  
    161161    """ 
    162162    # No image matrix given 
    163     if image == None or numpy.ndim(image) != 2 \ 
     163    if image is None or numpy.ndim(image) != 2 \ 
    164164            or numpy.isfinite(image).all() \ 
    165             or weights == None: 
     165            or weights is None: 
    166166        return image 
    167167    # Get bin size in y and x directions 
  • src/sas/qtgui/Plotting/Plottables.py

    • Property mode changed from 100755 to 100644
    rb3e8629 rcee5c78  
    227227            if p.hidden == True: 
    228228                continue 
    229             if not p.x == None: 
     229            if not p.x is None: 
    230230                for x_i in p.x: 
    231                     if min_value == None or x_i < min_value: 
     231                    if min_value is None or x_i < min_value: 
    232232                        min_value = x_i 
    233                     if max_value == None or x_i > max_value: 
     233                    if max_value is None or x_i > max_value: 
    234234                        max_value = x_i 
    235235        return min_value, max_value 
     
    560560        Returns True if there is no data stored in the plottable 
    561561        """ 
    562         if not self.x == None and len(self.x) == 0 \ 
    563             and not self.y == None and len(self.y) == 0: 
     562        if not self.x is None and len(self.x) == 0 \ 
     563            and not self.y is None and len(self.y) == 0: 
    564564            return True 
    565565        return False 
     
    795795        tempy = [] 
    796796        tempdy = [] 
    797         if self.dx == None: 
     797        if self.dx is None: 
    798798            self.dx = numpy.zeros(len(self.x)) 
    799         if self.dy == None: 
     799        if self.dy is None: 
    800800            self.dy = numpy.zeros(len(self.y)) 
    801801        if self.xLabel == "log10(x)": 
     
    825825        tempy = [] 
    826826        tempdy = [] 
    827         if self.dx == None: 
     827        if self.dx is None: 
    828828            self.dx = numpy.zeros(len(self.x)) 
    829         if self.dy == None: 
     829        if self.dy is None: 
    830830            self.dy = numpy.zeros(len(self.y)) 
    831831        if self.yLabel == "log10(y)": 
     
    858858        tempy = [] 
    859859        tempdy = [] 
    860         if self.dx == None: 
     860        if self.dx is None: 
    861861            self.dx = numpy.zeros(len(self.x)) 
    862         if self.dy == None: 
     862        if self.dy is None: 
    863863            self.dy = numpy.zeros(len(self.y)) 
    864         if xmin != None and xmax != None: 
     864        if xmin is not None and xmax is not None: 
    865865            for i in range(len(self.x)): 
    866866                if self.x[i] >= xmin and self.x[i] <= xmax: 
     
    12021202        """ 
    12031203        """ 
    1204         if  self._chisq == None: 
     1204        if  self._chisq is None: 
    12051205            chisqTxt = r'$\chi^2=$' 
    12061206        else: 
  • src/sas/qtgui/Plotting/Plotter.py

    • Property mode changed from 100755 to 100644
    rb3e8629 rcee5c78  
    617617        """ 
    618618        ax = event.inaxes 
    619         if ax == None: 
     619        if ax is None: 
    620620            return 
    621621        # Event occurred inside a plotting area 
     
    652652        step = event.step 
    653653 
    654         if ax != None: 
     654        if ax is not None: 
    655655            # Event occurred inside a plotting area 
    656656            lo, hi = ax.get_xlim() 
  • src/sas/qtgui/Plotting/Plotter2D.py

    rf4a1433 rcee5c78  
    281281        new_plot.id = "Circ avg " + self.data.name 
    282282        new_plot.is_data = True 
    283         variant_plot = QtCore.QVariant(new_plot) 
    284         GuiUtils.updateModelItemWithPlot(self._item, variant_plot, new_plot.id) 
     283        GuiUtils.updateModelItemWithPlot(self._item, new_plot, new_plot.id) 
    285284        self.manager.communicator.plotUpdateSignal.emit([new_plot]) 
    286285 
  • src/sas/qtgui/Plotting/PlotterData.py

    • Property mode changed from 100755 to 100644
    r749b715 rcee5c78  
    7272        result.clone_without_data(length=len(self.x), clone=self) 
    7373        result.copy_from_datainfo(data1d=self) 
    74         if self.dxw == None: 
     74        if self.dxw is None: 
    7575            result.dxw = None 
    7676        else: 
    7777            result.dxw = numpy.zeros(len(self.x)) 
    78         if self.dxl == None: 
     78        if self.dxl is None: 
    7979            result.dxl = None 
    8080        else: 
     
    119119        tot_length = len(self.x) + len(other.x) 
    120120        result = self.clone_without_data(length=tot_length, clone=result) 
    121         if self.dy == None or other.dy is None: 
     121        if self.dy is None or other.dy is None: 
    122122            result.dy = None 
    123123        else: 
    124124            result.dy = numpy.zeros(tot_length) 
    125         if self.dx == None or other.dx is None: 
     125        if self.dx is None or other.dx is None: 
    126126            result.dx = None 
    127127        else: 
    128128            result.dx = numpy.zeros(tot_length) 
    129         if self.dxw == None or other.dxw is None: 
     129        if self.dxw is None or other.dxw is None: 
    130130            result.dxw = None 
    131131        else: 
    132132            result.dxw = numpy.zeros(tot_length) 
    133         if self.dxl == None or other.dxl is None: 
     133        if self.dxl is None or other.dxl is None: 
    134134            result.dxl = None 
    135135        else: 
     
    142142        result.y = numpy.append(self.y, other.y) 
    143143        result.y = result.y[ind] 
    144         if result.dy != None: 
     144        if result.dy is not None: 
    145145            result.dy = numpy.append(self.dy, other.dy) 
    146146            result.dy = result.dy[ind] 
     
    239239        result.ymin = self.ymin 
    240240        result.ymax = self.ymax 
    241         if self.dqx_data == None or self.dqy_data == None: 
     241        if self.dqx_data is None or self.dqy_data is None: 
    242242            result.dqx_data = None 
    243243            result.dqy_data = None 
     
    302302        result.ymin = self.ymin 
    303303        result.ymax = self.ymax 
    304         if self.dqx_data == None or self.dqy_data == None or \ 
    305                 other.dqx_data == None or other.dqy_data == None : 
     304        if self.dqx_data is None or self.dqy_data is None or \ 
     305                other.dqx_data is None or other.dqy_data is None : 
    306306            result.dqx_data = None 
    307307            result.dqy_data = None 
  • src/sas/qtgui/Plotting/SlicerModel.py

    • Property mode changed from 100755 to 100644
    rb3e8629 rcee5c78  
    2323            item2 = QtGui.QStandardItem(GuiUtils.formatNumber(parameters[parameter])) 
    2424            self._model.appendRow([item1, item2]) 
    25         self._model.setHeaderData(0, QtCore.Qt.Horizontal, QtCore.QVariant("Parameter")) 
    26         self._model.setHeaderData(1, QtCore.Qt.Horizontal, QtCore.QVariant("Value")) 
     25        self._model.setHeaderData(0, QtCore.Qt.Horizontal, "Parameter") 
     26        self._model.setHeaderData(1, QtCore.Qt.Horizontal, "Value") 
    2727 
    2828    def setParamsFromModel(self, item): 
  • src/sas/qtgui/Plotting/Slicers/AnnulusSlicer.py

    • Property mode changed from 100755 to 100644
    rb3e8629 rcee5c78  
    145145        new_plot.xtransform = "x" 
    146146        new_plot.ytransform = "y" 
    147         variant_plot = QtCore.QVariant(new_plot) 
    148         GuiUtils.updateModelItemWithPlot(self._item, variant_plot, new_plot.id) 
     147        GuiUtils.updateModelItemWithPlot(self._item, new_plot, new_plot.id) 
    149148        self.base.manager.communicator.plotUpdateSignal.emit([new_plot]) 
    150149 
  • src/sas/qtgui/Plotting/Slicers/Arc.py

    • Property mode changed from 100755 to 100644
    rb3e8629 rcee5c78  
    7070        x = [] 
    7171        y = [] 
    72         if theta1 != None: 
     72        if theta1 is not None: 
    7373            self.theta1 = theta1 
    74         if theta2 != None: 
     74        if theta2 is not None: 
    7575            self.theta2 = theta2 
    7676        while self.theta2 < self.theta1: 
     
    8080        npts = int((self.theta2 - self.theta1) / (math.pi / 120)) 
    8181 
    82         if r == None: 
     82        if r is None: 
    8383            self.radius = math.sqrt(math.pow(self._mouse_x, 2) + \ 
    8484                                     math.pow(self._mouse_y, 2)) 
  • src/sas/qtgui/Plotting/Slicers/BoxSlicer.py

    • Property mode changed from 100755 to 100644
    rb3e8629 rcee5c78  
    190190        new_plot.id = (self.averager.__name__) + self.base.data.name 
    191191        new_plot.is_data = True 
    192         variant_plot = QtCore.QVariant(new_plot) 
    193         GuiUtils.updateModelItemWithPlot(self._item, variant_plot, new_plot.id) 
     192        GuiUtils.updateModelItemWithPlot(self._item, new_plot, new_plot.id) 
    194193 
    195194        if self.update_model: 
  • src/sas/qtgui/Plotting/Slicers/BoxSum.py

    • Property mode changed from 100755 to 100644
    rb3e8629 rcee5c78  
    110110        parameters = self.getParams() 
    111111        # Crete/overwrite model items 
    112         self._model.setData(self._model.index(0, 0), 
    113                     QtCore.QVariant(formatNumber(parameters['Height']))) 
    114         self._model.setData(self._model.index(0, 1), 
    115                     QtCore.QVariant(formatNumber(parameters['Width']))) 
    116         self._model.setData(self._model.index(0, 2), 
    117                     QtCore.QVariant(formatNumber(parameters['center_x']))) 
    118         self._model.setData(self._model.index(0, 3), 
    119                     QtCore.QVariant(formatNumber(parameters['center_y']))) 
     112        self._model.setData(self._model.index(0, 0), formatNumber(parameters['Height'])) 
     113        self._model.setData(self._model.index(0, 1), formatNumber(parameters['Width'])) 
     114        self._model.setData(self._model.index(0, 2), formatNumber(parameters['center_x'])) 
     115        self._model.setData(self._model.index(0, 3), formatNumber(parameters['center_y'])) 
    120116 
    121117        self.setReadOnlyParametersFromModel() 
     
    130126        """ 
    131127        parameters = self.getParams() 
    132         self._model.setData(self._model.index(0, 4), 
    133                     QtCore.QVariant(formatNumber(parameters['avg']))) 
    134         self._model.setData(self._model.index(0, 5), 
    135                     QtCore.QVariant(formatNumber(parameters['avg_error']))) 
    136         self._model.setData(self._model.index(0, 6), 
    137                     QtCore.QVariant(formatNumber(parameters['sum']))) 
    138         self._model.setData(self._model.index(0, 7), 
    139                     QtCore.QVariant(formatNumber(parameters['sum_error']))) 
    140         self._model.setData(self._model.index(0, 8), 
    141                     QtCore.QVariant(formatNumber(parameters['num_points']))) 
     128        self._model.setData(self._model.index(0, 4), formatNumber(parameters['avg'])) 
     129        self._model.setData(self._model.index(0, 5), formatNumber(parameters['avg_error'])) 
     130        self._model.setData(self._model.index(0, 6), formatNumber(parameters['sum'])) 
     131        self._model.setData(self._model.index(0, 7), formatNumber(parameters['sum_error'])) 
     132        self._model.setData(self._model.index(0, 8), formatNumber(parameters['num_points'])) 
    142133 
    143134    def setParamsFromModel(self): 
     
    362353        Draw the new roughness on the graph. 
    363354        """ 
    364         if center_x != None: 
     355        if center_x is not None: 
    365356            self.x = center_x 
    366         if center_y != None: 
     357        if center_y is not None: 
    367358            self.y = center_y 
    368359        self.center_marker.set(xdata=[self.x], ydata=[self.y]) 
  • src/sas/qtgui/Plotting/Slicers/SectorSlicer.py

    • Property mode changed from 100755 to 100644
    rb3e8629 rcee5c78  
    125125        data = self.base.data 
    126126        # If we have no data, just return 
    127         if data == None: 
     127        if data is None: 
    128128            return 
    129129        # Averaging 
     
    132132        phimin = -self.left_line.phi + self.main_line.theta 
    133133        phimax = self.left_line.phi + self.main_line.theta 
    134         if nbins == None: 
     134        if nbins is None: 
    135135            nbins = 20 
    136136        sect = SectorQ(r_min=0.0, r_max=radius, 
     
    168168        new_plot.id = "SectorQ" + self.base.data.name 
    169169        new_plot.is_data = True 
    170         variant_plot = QtCore.QVariant(new_plot) 
    171         GuiUtils.updateModelItemWithPlot(self._item, variant_plot, new_plot.id) 
     170        GuiUtils.updateModelItemWithPlot(self._item, new_plot, new_plot.id) 
    172171        self.base.manager.communicator.plotUpdateSignal.emit([new_plot]) 
    173172 
     
    349348        self.left_moving = left 
    350349        theta3 = 0 
    351         if phi != None: 
     350        if phi is not None: 
    352351            self.phi = phi 
    353         if delta == None: 
     352        if delta is None: 
    354353            delta = 0 
    355354        if  right: 
     
    361360            self.theta = mline.theta + self.phi 
    362361 
    363         if mline != None: 
     362        if mline is not None: 
    364363            if delta != 0: 
    365364                self.theta2 = mline + delta 
     
    509508        """ 
    510509 
    511         if theta != None: 
     510        if theta is not None: 
    512511            self.theta = theta 
    513512        x1 = self.radius * numpy.cos(self.theta) 
  • src/sas/qtgui/Plotting/UnitTesting/BoxSumTest.py

    r464cd07 rcee5c78  
    2323        parameters = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0] 
    2424        for index, parameter in enumerate(parameters): 
    25             model.setData(model.index(0, index), 
    26                     QtCore.QVariant(parameter)) 
     25            model.setData(model.index(0, index),parameter) 
    2726        self.widget = BoxSum(None, model=model) 
    2827 
Note: See TracChangeset for help on using the changeset viewer.