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


Ignore:
Timestamp:
Nov 9, 2017 8:41:54 AM (7 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:
cee5c78
Parents:
749b715
git-author:
Piotr Rozyczko <rozyczko@…> (10/26/17 03:13:05)
git-committer:
Piotr Rozyczko <rozyczko@…> (11/09/17 08:41:54)
Message:

Initial changes to make SasView? run with python3

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

Legend:

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

    rfef38e8 rb3e8629  
    5959            return 
    6060        xs3d, ys3d, zs3d = self._verts3d 
    61         for i in xrange(len(xs3d)): 
     61        for i in range(len(xs3d)): 
    6262            xs, ys, _ = proj3d.proj_transform(xs3d[i], ys3d[i], zs3d[i], renderer.M) 
    6363            self.set_positions((xs[0], ys[0]), (xs[1], ys[1])) 
  • src/sas/qtgui/Plotting/Binder.py

    rdc5ef15 rb3e8629  
    2424        return self.artist is not other.artist 
    2525 
    26     def __nonzero__(self): 
     26    def __bool__(self): 
    2727        return self.artist is not None 
    2828 
     
    6161            ] 
    6262        except: 
    63             print "bypassing scroll_event: wrong matplotlib version" 
     63            print("bypassing scroll_event: wrong matplotlib version") 
    6464            self._connections = [ 
    6565                canvas.mpl_connect('motion_notify_event', self._onMotion), 
     
    121121            for cid in self._connections: self.canvas.mpl_disconnect(cid) 
    122122        except: 
    123             logging.error("Error disconnection canvas: %s" % sys.exc_value) 
     123            logging.error("Error disconnection canvas: %s" % sys.exc_info()[1]) 
    124124        self._connections = [] 
    125125 
     
    185185        # Check that the trigger is valid 
    186186        if trigger not in self._actions: 
    187             raise ValueError, "%s invalid --- valid triggers are %s"\ 
    188                  % (trigger, ", ".join(self.events)) 
     187            raise ValueError("%s invalid --- valid triggers are %s"\ 
     188                 % (trigger, ", ".join(self.events))) 
    189189 
    190190        # Register the trigger callback 
     
    201201        """ 
    202202        if action not in self.events: 
    203             raise ValueError, "Trigger expects " + ", ".join(self.events) 
     203            raise ValueError("Trigger expects " + ", ".join(self.events)) 
    204204 
    205205        # Tag the event with modifiers 
  • src/sas/qtgui/Plotting/ColorMap.py

    • Property mode changed from 100644 to 100755
    rdc5ef15 rb3e8629  
    1313from sas.qtgui.Plotting.PlotterData import Data2D 
    1414from sas.qtgui.Utilities.GuiUtils import formatNumber 
    15 from rangeSlider import RangeSlider 
     15from .rangeSlider import RangeSlider 
    1616 
    1717DEFAULT_MAP = 'jet' 
  • src/sas/qtgui/Plotting/ConvertUnits.py

    r749b715 rb3e8629  
    4242                            unit = toks[0] + "^{" + str(powerer) + "}" 
    4343                else: 
    44                     raise ValueError, "missing } in unit expression" 
     44                    raise ValueError("missing } in unit expression") 
    4545        else:  # no powerer 
    4646            if  power != 1: 
    4747                unit = "(" + unit + ")" + "^{" + str(power) + "}" 
    4848    else: 
    49         raise ValueError, "empty unit ,enter a powerer different from zero" 
     49        raise ValueError("empty unit ,enter a powerer different from zero") 
    5050    return unit 
    5151 
     
    6868    unit8 = "m/s^{4}"  #         x^2               (m/s^{4})^{2} 
    6969 
    70     print "this unit1 %s ,its powerer %s , and value %s" % (unit1, 1, convert_unit(1, unit1)) 
    71     print "this unit2 %s ,its powerer %s , and value %s" % (unit2, 1, convert_unit(1, unit2)) 
    72     print "this unit3 %s ,its powerer %s , and value %s" % (unit3, 2, convert_unit(2, unit3)) 
    73     print "this unit4 %s ,its powerer %s , and value %s" % (unit4, -1, convert_unit(-1, unit4)) 
    74     print "this unit5 %s ,its powerer %s , and value %s" % (unit5, 2, convert_unit(2, unit5)) 
    75     print "this unit6 %s ,its powerer %s , and value %s" % (unit6, 2, convert_unit(2, unit6)) 
    76     print "this unit7 %s ,its powerer %s , and value %s" % (unit7, -1, convert_unit(-1, unit7)) 
    77     print "this unit8 %s ,its powerer %s , and value %s" % (unit8, 2, convert_unit(2, unit8)) 
    78     print "this unit9 %s ,its powerer %s , and value %s" % (unit9, 2, convert_unit(2, unit9)) 
     70    print("this unit1 %s ,its powerer %s , and value %s" % (unit1, 1, convert_unit(1, unit1))) 
     71    print("this unit2 %s ,its powerer %s , and value %s" % (unit2, 1, convert_unit(1, unit2))) 
     72    print("this unit3 %s ,its powerer %s , and value %s" % (unit3, 2, convert_unit(2, unit3))) 
     73    print("this unit4 %s ,its powerer %s , and value %s" % (unit4, -1, convert_unit(-1, unit4))) 
     74    print("this unit5 %s ,its powerer %s , and value %s" % (unit5, 2, convert_unit(2, unit5))) 
     75    print("this unit6 %s ,its powerer %s , and value %s" % (unit6, 2, convert_unit(2, unit6))) 
     76    print("this unit7 %s ,its powerer %s , and value %s" % (unit7, -1, convert_unit(-1, unit7))) 
     77    print("this unit8 %s ,its powerer %s , and value %s" % (unit8, 2, convert_unit(2, unit8))) 
     78    print("this unit9 %s ,its powerer %s , and value %s" % (unit9, 2, convert_unit(2, unit9))) 
    7979 
    8080 
  • src/sas/qtgui/Plotting/DataTransform.py

    r749b715 rb3e8629  
    2424    """ 
    2525    if not x > 0: 
    26         raise ValueError, "Transformation only accepts positive values." 
     26        raise ValueError("Transformation only accepts positive values.") 
    2727    else: 
    2828        return x 
     
    5050    """ 
    5151    if not x >= 0: 
    52         raise ValueError, "square root of a negative value " 
     52        raise ValueError("square root of a negative value ") 
    5353    else: 
    5454        return math.sqrt(x) 
     
    7676    """ 
    7777    if not x >= 0: 
    78         raise ValueError, "double square root of a negative value " 
     78        raise ValueError("double square root of a negative value ") 
    7979    else: 
    8080        return math.sqrt(math.sqrt(x)) 
     
    9090    """ 
    9191    if not x > 0: 
    92         raise ValueError, "Log(x)of a negative value " 
     92        raise ValueError("Log(x)of a negative value ") 
    9393    else: 
    9494        return math.log(x) 
     
    100100        return 1 / x 
    101101    else: 
    102         raise ValueError, "cannot divide by zero" 
     102        raise ValueError("cannot divide by zero") 
    103103 
    104104 
     
    109109        return 1 / math.sqrt(y) 
    110110    else: 
    111         raise ValueError, "transform.toOneOverSqrtX: cannot be computed" 
     111        raise ValueError("transform.toOneOverSqrtX: cannot be computed") 
    112112 
    113113 
     
    118118        return math.log(y * (x ** 2)) 
    119119    else: 
    120         raise ValueError, "transform.toLogYX2: cannot be computed" 
     120        raise ValueError("transform.toLogYX2: cannot be computed") 
    121121 
    122122 
     
    127127        return math.log(math.pow(x, 4) * y) 
    128128    else: 
    129         raise ValueError, "transform.toLogYX4: input error" 
     129        raise ValueError("transform.toLogYX4: input error") 
    130130 
    131131 
     
    149149    """ 
    150150    if not (x * y) > 0: 
    151         raise ValueError, "Log(X*Y)of a negative value " 
     151        raise ValueError("Log(X*Y)of a negative value ") 
    152152    else: 
    153153        return math.log(x * y) 
     
    211211    else: 
    212212        msg = "transform.errFromX2: can't compute error of negative x" 
    213         raise ValueError, msg 
     213        raise ValueError(msg) 
    214214 
    215215 
     
    245245    else: 
    246246        msg = "transform.errFromX4: can't compute error of negative x" 
    247         raise ValueError, msg 
     247        raise ValueError(msg) 
    248248 
    249249 
     
    264264        msg = "Transformation does not accept" 
    265265        msg += " point that are consistent with zero." 
    266         raise ValueError, msg 
     266        raise ValueError(msg) 
    267267    if x != 0: 
    268268        dx = dx / (x * math.log(10)) 
    269269    else: 
    270         raise ValueError, "errToLogX: divide by zero" 
     270        raise ValueError("errToLogX: divide by zero") 
    271271    return dx 
    272272 
     
    287287        dx = dx / x 
    288288    else: 
    289         raise ValueError, "errToLogX: divide by zero" 
     289        raise ValueError("errToLogX: divide by zero") 
    290290    return dx 
    291291 
     
    312312        msg = "Transformation does not accept point " 
    313313        msg += " that are consistent with zero." 
    314         raise ValueError, msg 
     314        raise ValueError(msg) 
    315315    if x != 0 and y != 0: 
    316316        if dx == None: 
     
    320320        err = (dx / x) ** 2 + (dy / y) ** 2 
    321321    else: 
    322         raise ValueError, "cannot compute this error" 
     322        raise ValueError("cannot compute this error") 
    323323 
    324324    return math.sqrt(math.fabs(err)) 
     
    335335        msg = "Transformation does not accept point" 
    336336        msg += " that are consistent with zero." 
    337         raise ValueError, msg 
     337        raise ValueError(msg) 
    338338    if x > 0 and y > 0: 
    339339        if dx == None: 
     
    343343        err = (2.0 * dx / x) ** 2 + (dy / y) ** 2 
    344344    else: 
    345         raise ValueError, "cannot compute this error" 
     345        raise ValueError("cannot compute this error") 
    346346    return math.sqrt(math.fabs(err)) 
    347347 
     
    357357        err = dx / x ** 2 
    358358    else: 
    359         raise ValueError, "Cannot compute this error" 
     359        raise ValueError("Cannot compute this error") 
    360360    return math.fabs(err) 
    361361 
     
    371371        err = -1 / 2 * math.pow(x, -3.0 / 2.0) * dx 
    372372    else: 
    373         raise ValueError, "Cannot compute this error" 
     373        raise ValueError("Cannot compute this error") 
    374374    return math.fabs(err) 
    375375 
     
    387387        msg = "Transformation does not accept point " 
    388388        msg += " that are consistent with zero." 
    389         raise ValueError, msg 
     389        raise ValueError(msg) 
    390390    if dx == None: 
    391391        dx = 0 
  • src/sas/qtgui/Plotting/Fittings.py

    • Property mode changed from 100644 to 100755
    radc49fc rb3e8629  
    9797    # Testing implementation 
    9898    # Fit a Line model 
    99     from LineModel import LineModel 
     99    from .LineModel import LineModel 
    100100    line = LineModel() 
    101101    cstA = Parameter(line, 'A', event.cstA) 
     
    104104    chisqr, out, cov = sasfit(line, [cstA, cstB], event.x, y, 0) 
    105105    # print "Output parameters:", out 
    106     print "The right answer is [70.0, 1.0]" 
    107     print chisqr, out, cov 
     106    print("The right answer is [70.0, 1.0]") 
     107    print(chisqr, out, cov) 
    108108 
  • src/sas/qtgui/Plotting/LineModel.py

    r749b715 rb3e8629  
    8181        elif x.__class__.__name__ == 'tuple': 
    8282            msg = "Tuples are not allowed as input to BaseComponent models" 
    83             raise ValueError, msg 
     83            raise ValueError(msg) 
    8484        else: 
    8585            return self._line(x) 
     
    103103        elif x.__class__.__name__ == 'tuple': 
    104104            msg = "Tuples are not allowed as input to BaseComponent models" 
    105             raise ValueError, msg 
     105            raise ValueError(msg) 
    106106        else: 
    107107            return self._line(x) 
  • src/sas/qtgui/Plotting/LinearFit.py

    • Property mode changed from 100644 to 100755
    rdc5ef15 rb3e8629  
    7979        Overwrite default fit range label to correspond to actual unit 
    8080        """ 
    81         assert(isinstance(label, basestring)) 
     81        assert(isinstance(label, str)) 
    8282        self.lblRange.setText(label) 
    8383 
     
    195195                         for i in range(len(x)) if x[i] >= xmin_check] 
    196196            else: 
    197                 tempy = map(numpy.log10, y) 
    198                 tempdy = map(lambda t1,t2:DataTransform.errToLogX(t1,0,t2,0),y,dy) 
     197                tempy = list(map(numpy.log10, y)) 
     198                tempdy = list(map(lambda t1,t2:DataTransform.errToLogX(t1,0,t2,0),y,dy)) 
    199199        else: 
    200200            tempy = y 
  • src/sas/qtgui/Plotting/PlotHelper.py

    • Property mode changed from 100644 to 100755
    r83eb5208 rb3e8629  
    3535    Returns a list of IDs for all currently active plots 
    3636    """ 
    37     return this._plots.keys() 
     37    return list(this._plots.keys()) 
    3838 
    3939def plotById(plot_id): 
     
    4848    """ 
    4949    plot_id = None 
    50     for key in this._plots.keys(): 
     50    for key in list(this._plots.keys()): 
    5151        if this._plots[key] == plot: 
    5252            plot_id = key 
  • src/sas/qtgui/Plotting/PlotProperties.py

    • Property mode changed from 100644 to 100755
    rcd2cc745 rb3e8629  
    2626 
    2727        # Fill out the color combobox 
    28         self.cbColor.addItems(COLORS.keys()[:-1]) 
     28        self.cbColor.addItems(list(COLORS.keys())[:-1]) 
    2929        # data1d.custom_color can now be a simple integer, 
    3030        # specifying COLORS dict index or a string containing 
     
    3434        else: 
    3535            # Need the Custom entry here. "Custom" is always last. 
    36             self.cbColor.addItems([COLORS.keys()[-1]]) 
    37             self.cbColor.setCurrentIndex(COLORS.keys().index("Custom")) 
     36            self.cbColor.addItems([list(COLORS.keys())[-1]]) 
     37            self.cbColor.setCurrentIndex(list(COLORS.keys()).index("Custom")) 
    3838 
    3939        # Fill out the marker combobox 
    40         self.cbShape.addItems(SHAPES.keys()) 
     40        self.cbShape.addItems(list(SHAPES.keys())) 
    4141        try: 
    4242            self.cbShape.setCurrentIndex(self._marker) 
     
    8383            # Add Custom to the color combo box 
    8484            self.cbColor.addItems(["Custom"]) 
    85             self.cbColor.setCurrentIndex(COLORS.keys().index("Custom")) 
     85            self.cbColor.setCurrentIndex(list(COLORS.keys()).index("Custom")) 
    8686            # unblock currentIndexChanged 
    8787            self.cbColor.blockSignals(False) 
  • src/sas/qtgui/Plotting/PlotUtilities.py

    • Property mode changed from 100644 to 100755
    r83eb5208 rb3e8629  
    273273        # Check if it's within the range 
    274274        if 0 <= color <=6: 
    275             color = COLORS.values()[color] 
     275            color = list(COLORS.values())[color] 
    276276    # Check if it's an RGB string 
    277277    elif isinstance(color, str): 
  • src/sas/qtgui/Plotting/Plottables.py

    rdc5ef15 rb3e8629  
    239239        selected_color = None 
    240240        selected_plottable = None 
    241         for p in self.plottables.keys(): 
     241        for p in list(self.plottables.keys()): 
    242242            if plottable.id == p.id: 
    243243                selected_plottable = p 
     
    384384 
    385385        """ 
    386         raise NotImplemented, "Not a valid transform" 
     386        raise NotImplemented("Not a valid transform") 
    387387 
    388388    # Related issues 
     
    512512                label_dict[collection[0]] = basename 
    513513            else: 
    514                 for i in xrange(len(collection)): 
     514                for i in range(len(collection)): 
    515515                    label_dict[collection[i]] = "%s %d" % (basename, i) 
    516516        return label_dict 
     
    684684                msg = "Plottable.View: Given x and dx are not" 
    685685                msg += " of the same length" 
    686                 raise ValueError, msg 
     686                raise ValueError(msg) 
    687687            # Check length of y array 
    688688            if not len(y) == len(x): 
    689689                msg = "Plottable.View: Given y " 
    690690                msg += "and x are not of the same length" 
    691                 raise ValueError, msg 
     691                raise ValueError(msg) 
    692692 
    693693            if not dy is None and not len(dy) == 0 and not len(y) == len(dy): 
    694694                msg = "Plottable.View: Given y and dy are not of the same " 
    695695                msg += "length: len(y)=%s, len(dy)=%s" % (len(y), len(dy)) 
    696                 raise ValueError, msg 
     696                raise ValueError(msg) 
    697697            self.x = [] 
    698698            self.y = [] 
     
    729729                msg = "Plottable.View: transformed x " 
    730730                msg += "and y are not of the same length" 
    731                 raise ValueError, msg 
     731                raise ValueError(msg) 
    732732            if has_err_x and not (len(self.x) == len(self.dx)): 
    733733                msg = "Plottable.View: transformed x and dx" 
    734734                msg += " are not of the same length" 
    735                 raise ValueError, msg 
     735                raise ValueError(msg) 
    736736            if has_err_y and not (len(self.y) == len(self.dy)): 
    737737                msg = "Plottable.View: transformed y" 
    738738                msg += " and dy are not of the same length" 
    739                 raise ValueError, msg 
     739                raise ValueError(msg) 
    740740            # Check that negative values are not plot on x and y axis for 
    741741            # log10 transformation 
     
    809809                except: 
    810810                    logging.error("check_data_logX: skipping point x %g", self.x[i]) 
    811                     logging.error(sys.exc_value) 
     811                    logging.error(sys.exc_info()[1]) 
    812812            self.x = tempx 
    813813            self.y = tempy 
     
    839839                except: 
    840840                    logging.error("check_data_logY: skipping point %g", self.y[i]) 
    841                     logging.error(sys.exc_value) 
     841                    logging.error(sys.exc_info()[1]) 
    842842 
    843843            self.x = tempx 
     
    11011101        Plottable.__init__(self) 
    11021102        msg = "Theory1D is no longer supported, please use Data1D and change symbol.\n" 
    1103         raise DeprecationWarning, msg 
     1103        raise DeprecationWarning(msg) 
    11041104 
    11051105class PlottableFit1D(Plottable): 
  • src/sas/qtgui/Plotting/Plotter.py

    • Property mode changed from 100644 to 100755
    r749b715 rb3e8629  
    9090                marker = PlotUtilities.SHAPES[marker] 
    9191            except KeyError: 
    92                 marker = PlotUtilities.SHAPES.values()[marker] 
     92                marker = list(PlotUtilities.SHAPES.values())[marker] 
    9393 
    9494        assert marker is not None 
     
    206206        Adds operations on all plotted sets of data to the context menu 
    207207        """ 
    208         for id in self.plot_dict.keys(): 
     208        for id in list(self.plot_dict.keys()): 
    209209            plot = self.plot_dict[id] 
    210210 
     
    391391        Deletes the selected plot from the chart 
    392392        """ 
    393         if id not in self.plot_dict.keys(): 
     393        if id not in list(self.plot_dict.keys()): 
    394394            return 
    395395 
     
    482482        """ 
    483483        # Transform all the plots on the chart 
    484         for id in self.plot_dict.keys(): 
     484        for id in list(self.plot_dict.keys()): 
    485485            current_plot = self.plot_dict[id] 
    486486            if current_plot.id == "fit": 
  • src/sas/qtgui/Plotting/SlicerModel.py

    • Property mode changed from 100644 to 100755
    r83eb5208 rb3e8629  
    1919        self._model.removeRows( 0, self._model.rowCount() ) 
    2020        # Crete/overwrite model items 
    21         for parameter in parameters.keys(): 
     21        for parameter in list(parameters.keys()): 
    2222            item1 = QtGui.QStandardItem(parameter) 
    2323            item2 = QtGui.QStandardItem(GuiUtils.formatNumber(parameters[parameter])) 
  • src/sas/qtgui/Plotting/Slicers/AnnulusSlicer.py

    rdc5ef15 rb3e8629  
    44 
    55import sas.qtgui.Utilities.GuiUtils as GuiUtils 
    6 from BaseInteractor import BaseInteractor 
     6from .BaseInteractor import BaseInteractor 
    77from sas.qtgui.Plotting.PlotterData import Data1D 
    88from sas.qtgui.Utilities.GuiUtils import formatNumber 
  • src/sas/qtgui/Plotting/Slicers/Arc.py

    r749b715 rb3e8629  
    44import math 
    55 
    6 from BaseInteractor import BaseInteractor 
     6from .BaseInteractor import BaseInteractor 
    77 
    88class ArcInteractor(BaseInteractor): 
  • src/sas/qtgui/Plotting/Slicers/AzimutSlicer.py

    rdc5ef15 rb3e8629  
    55# 
    66import math 
    7 from BaseInteractor import BaseInteractor 
     7from .BaseInteractor import BaseInteractor 
    88 
    99class SectorInteractor(BaseInteractor): 
     
    2626 
    2727        # Inner circle 
    28         from Arc import ArcInteractor 
     28        from .Arc import ArcInteractor 
    2929        self.inner_circle = ArcInteractor(self, self.base.subplot, 
    3030                                          zorder=zorder, 
  • src/sas/qtgui/Plotting/Slicers/BoxSlicer.py

    rdc5ef15 rb3e8629  
    33from PyQt4 import QtCore 
    44 
    5 from BaseInteractor import BaseInteractor 
     5from .BaseInteractor import BaseInteractor 
    66from sas.qtgui.Plotting.PlotterData import Data1D 
    77import sas.qtgui.Utilities.GuiUtils as GuiUtils 
     
    136136            if new_slab is None: 
    137137                msg = "post data:cannot average , averager is empty" 
    138                 raise ValueError, msg 
     138                raise ValueError(msg) 
    139139            self.averager = new_slab 
    140140        if self.direction == "X": 
     
    152152        else: 
    153153            msg = "post data:no Box Average direction was supplied" 
    154             raise ValueError, msg 
     154            raise ValueError(msg) 
    155155        # # Average data2D given Qx or Qy 
    156156        box = self.averager(x_min=x_min, x_max=x_max, y_min=y_min, y_max=y_max, 
  • src/sas/qtgui/Plotting/Slicers/BoxSum.py

    rdc5ef15 rb3e8629  
    88from sas.qtgui.Utilities.GuiUtils import formatNumber 
    99 
    10 from BaseInteractor import BaseInteractor 
     10from .BaseInteractor import BaseInteractor 
    1111from sas.sascalc.dataloader.manipulations import Boxavg 
    1212from sas.sascalc.dataloader.manipulations import Boxsum 
  • src/sas/qtgui/Plotting/Slicers/SectorSlicer.py

    rdc5ef15 rb3e8629  
    66from PyQt4 import QtCore 
    77 
    8 from BaseInteractor import BaseInteractor 
     8from .BaseInteractor import BaseInteractor 
    99from sas.qtgui.Plotting.PlotterData import Data1D 
    1010import sas.qtgui.Utilities.GuiUtils as GuiUtils 
     
    230230            msg = "Phi left and phi right are different" 
    231231            msg += " %f, %f" % (self.left_line.phi, self.right_line.phi) 
    232             raise ValueError, msg 
     232            raise ValueError(msg) 
    233233        params["Phi [deg]"] = self.main_line.theta * 180 / numpy.pi 
    234234        params["Delta_Phi [deg]"] = numpy.fabs(self.left_line.phi * 180 / numpy.pi) 
Note: See TracChangeset for help on using the changeset viewer.