Changeset fa81e94 in sasview for src/sas/sasgui/plottools
- Timestamp:
- Nov 15, 2017 4:33:09 AM (7 years ago)
- 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:
- d4881f6a
- Parents:
- 7c487846
- Location:
- src/sas/sasgui/plottools
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/plottools/LineModel.py
- Property mode changed from 100644 to 100755
ra26f67f rfa81e94 83 83 elif x.__class__.__name__ == 'tuple': 84 84 msg = "Tuples are not allowed as input to BaseComponent models" 85 raise ValueError , msg85 raise ValueError(msg) 86 86 else: 87 87 return self._line(x) … … 105 105 elif x.__class__.__name__ == 'tuple': 106 106 msg = "Tuples are not allowed as input to BaseComponent models" 107 raise ValueError , msg107 raise ValueError(msg) 108 108 else: 109 109 return self._line(x) -
src/sas/sasgui/plottools/PlotPanel.py
- Property mode changed from 100644 to 100755
ra1b8fee rfa81e94 2 2 Plot panel. 3 3 """ 4 from __future__ import print_function 4 5 5 6 6 import logging … … 16 16 from matplotlib.figure import Figure 17 17 import os 18 import transform18 from . import transform 19 19 #TODO: make the plottables interactive 20 from binder import BindArtist20 from .binder import BindArtist 21 21 from matplotlib.font_manager import FontProperties 22 22 DEBUG = False 23 23 24 from plottables import Graph25 from TextDialog import TextDialog26 from LabelDialog import LabelDialog24 from .plottables import Graph 25 from .TextDialog import TextDialog 26 from .LabelDialog import LabelDialog 27 27 import operator 28 28 … … 44 44 for a in obj.get_children(): show_tree(a, d + 1) 45 45 46 from convert_units import convert_unit46 from .convert_units import convert_unit 47 47 48 48 … … 116 116 self.figure = Figure(None, dpi, linewidth=2.0) 117 117 self.color = '#b3b3b3' 118 from canvas import FigureCanvas118 from .canvas import FigureCanvas 119 119 self.canvas = FigureCanvas(self, -1, self.figure) 120 120 self.SetColor(color) … … 657 657 else: 658 658 plot_dict = plotlist 659 from fitDialog import LinearFit660 661 if len( plot_dict.keys()) > 0:662 first_item = plot_dict.keys()[0]659 from .fitDialog import LinearFit 660 661 if len(list(plot_dict.keys())) > 0: 662 first_item = list(plot_dict.keys())[0] 663 663 dlg = LinearFit(parent=None, plottable=first_item, 664 664 push_data=self.onFitDisplay, … … 691 691 return 692 692 name = menu.GetHelpString(id) 693 for plot in self.plots.values():693 for plot in list(self.plots.values()): 694 694 if plot.name == name: 695 695 self.graph.selected_plottable = plot.id … … 703 703 704 704 """ 705 from fitDialog import LinearFit705 from .fitDialog import LinearFit 706 706 if self._fit_dialog is not None: 707 707 return … … 733 733 self._fit_dialog = None 734 734 plot_list = self.graph.returnPlottable() 735 if len( plot_list.keys()) > 0:736 first_item = plot_list.keys()[0]735 if len(list(plot_list.keys())) > 0: 736 first_item = list(plot_list.keys())[0] 737 737 if first_item.x != []: 738 from PropertyDialog import Properties738 from .PropertyDialog import Properties 739 739 dial = Properties(self, -1, 'Properties') 740 740 dial.setValues(self.prevXtrans, self.prevYtrans, self.viewModel) … … 956 956 hl = sorted(zip(handles, labels), 957 957 key=operator.itemgetter(1)) 958 handles2, labels2 = zip(*hl)958 handles2, labels2 = list(zip(*hl)) 959 959 self.line_collections_list = handles2 960 960 self.legend = self.subplot.legend(handles2, labels2, … … 986 986 hl = sorted(zip(handles, labels), 987 987 key=operator.itemgetter(1)) 988 handles2, labels2 = zip(*hl)988 handles2, labels2 = list(zip(*hl)) 989 989 self.line_collections_list = handles2 990 990 self.legend = self.subplot.legend(handles2, labels2, … … 1247 1247 hl = sorted(zip(handles, labels), 1248 1248 key=operator.itemgetter(1)) 1249 handles2, labels2 = zip(*hl)1249 handles2, labels2 = list(zip(*hl)) 1250 1250 self.line_collections_list = handles2 1251 1251 self.legend = ax.legend(handles2, labels2, … … 1327 1327 if id is None: 1328 1328 id = name 1329 from plottable_interactor import PointInteractor1329 from .plottable_interactor import PointInteractor 1330 1330 p = PointInteractor(self, self.subplot, zorder=zorder, id=id) 1331 1331 if p.markersize is not None: … … 1344 1344 if id is None: 1345 1345 id = name 1346 from plottable_interactor import PointInteractor1346 from .plottable_interactor import PointInteractor 1347 1347 p = PointInteractor(self, self.subplot, zorder=zorder, id=id) 1348 1348 p.curve(x, y, dy=dy, color=color, symbol=symbol, zorder=zorder, … … 1754 1754 self.graph.delete(self.fit_result) 1755 1755 if hasattr(self, 'plots'): 1756 if 'fit' in self.plots.keys():1756 if 'fit' in list(self.plots.keys()): 1757 1757 del self.plots['fit'] 1758 1758 self.ly = None -
src/sas/sasgui/plottools/__init__.py
- Property mode changed from 100644 to 100755
refe730d rfa81e94 1 from PlotPanel import PlotPanel2 from plottables import Data1D, Theory1D1 from .PlotPanel import PlotPanel 2 from .plottables import Data1D, Theory1D -
src/sas/sasgui/plottools/arrow3d.py
- Property mode changed from 100644 to 100755
r7432acb rfa81e94 59 59 return 60 60 xs3d, ys3d, zs3d = self._verts3d 61 for i in xrange(len(xs3d)):61 for i in range(len(xs3d)): 62 62 xs, ys, _ = proj3d.proj_transform(xs3d[i], ys3d[i], zs3d[i], renderer.M) 63 63 self.set_positions((xs[0], ys[0]), (xs[1], ys[1])) -
src/sas/sasgui/plottools/binder.py
- Property mode changed from 100644 to 100755
ra1b8fee rfa81e94 2 2 Extension to MPL to support the binding of artists to key/mouse events. 3 3 """ 4 from __future__ import print_function 4 5 5 6 6 import sys … … 28 28 return self.artist is not other.artist 29 29 30 def __ nonzero__(self):30 def __bool__(self): 31 31 return self.artist is not None 32 32 … … 125 125 for cid in self._connections: self.canvas.mpl_disconnect(cid) 126 126 except: 127 logger.error("Error disconnection canvas: %s" % sys.exc_ value)127 logger.error("Error disconnection canvas: %s" % sys.exc_info()[1]) 128 128 self._connections = [] 129 129 … … 189 189 # Check that the trigger is valid 190 190 if trigger not in self._actions: 191 raise ValueError ,"%s invalid --- valid triggers are %s"\192 % (trigger, ", ".join(self.events)) 191 raise ValueError("%s invalid --- valid triggers are %s"\ 192 % (trigger, ", ".join(self.events))) 193 193 194 194 # Register the trigger callback … … 205 205 """ 206 206 if action not in self.events: 207 raise ValueError , "Trigger expects " + ", ".join(self.events)207 raise ValueError("Trigger expects " + ", ".join(self.events)) 208 208 209 209 # Tag the event with modifiers -
src/sas/sasgui/plottools/canvas.py
- Property mode changed from 100644 to 100755
r7432acb rfa81e94 98 98 dc.DrawBitmap(self.canvas.bitmap, (0, 0)) 99 99 except: 100 logger.error(sys.exc_ value)100 logger.error(sys.exc_info()[1]) 101 101 102 102 # restore original figure resolution … … 209 209 fig.draw(self) 210 210 except ValueError: 211 logger.error(sys.exc_ value)211 logger.error(sys.exc_info()[1]) 212 212 else: 213 213 self._isRendered = False -
src/sas/sasgui/plottools/convert_units.py
- Property mode changed from 100644 to 100755
ra1b8fee rfa81e94 3 3 This is a cleaned up version of unitConverter.py 4 4 """ 5 from __future__ import print_function 5 6 6 7 7 import re … … 44 44 unit = toks[0] + "^{" + str(powerer) + "}" 45 45 else: 46 raise ValueError , "missing } in unit expression"46 raise ValueError("missing } in unit expression") 47 47 else: # no powerer 48 48 if power != 1: 49 49 unit = "(" + unit + ")" + "^{" + str(power) + "}" 50 50 else: 51 raise ValueError , "empty unit ,enter a powerer different from zero"51 raise ValueError("empty unit ,enter a powerer different from zero") 52 52 return unit 53 53 -
src/sas/sasgui/plottools/fitDialog.py
- Property mode changed from 100644 to 100755
r7432acb rfa81e94 1 1 import wx 2 from plottables import Theory1D2 from .plottables import Theory1D 3 3 import math 4 4 import numpy as np 5 import fittings6 import transform5 from . import fittings 6 from . import transform 7 7 import sys 8 8 … … 86 86 self.layout() 87 87 # Receives the type of model for the fitting 88 from LineModel import LineModel88 from .LineModel import LineModel 89 89 self.model = LineModel() 90 90 # Display the fittings values … … 671 671 return x 672 672 else: 673 raise ValueError , "cannot compute log of a negative number"673 raise ValueError("cannot compute log of a negative number") 674 674 675 675 def floatInvTransform(self, x): … … 734 734 except: 735 735 msg = "LinearFit.set_fit_region: fit range must be floats" 736 raise ValueError , msg736 raise ValueError(msg) 737 737 self.xminFit.SetValue(format_number(xmin)) 738 738 self.xmaxFit.SetValue(format_number(xmax)) -
src/sas/sasgui/plottools/fittings.py
- Property mode changed from 100644 to 100755
ra1b8fee rfa81e94 14 14 15 15 """ 16 from __future__ import print_function 16 17 17 18 18 from scipy import optimize … … 101 101 # Testing implementation 102 102 # Fit a Line model 103 from LineModel import LineModel103 from .LineModel import LineModel 104 104 line = LineModel() 105 105 cstA = Parameter(line, 'A', event.cstA) -
src/sas/sasgui/plottools/plottable_interactor.py
- Property mode changed from 100644 to 100755
ra1b8fee rfa81e94 2 2 This module allows more interaction with the plot 3 3 """ 4 from __future__ import print_function 5 6 from BaseInteractor import _BaseInteractor4 5 6 from .BaseInteractor import _BaseInteractor 7 7 8 8 -
src/sas/sasgui/plottools/plottables.py
- Property mode changed from 100644 to 100755
r2d9526d rfa81e94 242 242 selected_color = plottable.custom_color 243 243 selected_plottable = None 244 for p in self.plottables.keys():244 for p in list(self.plottables.keys()): 245 245 if plottable.id == p.id: 246 246 selected_plottable = p … … 389 389 390 390 """ 391 raise NotImplemented , "Not a valid transform"391 raise NotImplemented("Not a valid transform") 392 392 393 393 # Related issues … … 517 517 label_dict[collection[0]] = basename 518 518 else: 519 for i in xrange(len(collection)):519 for i in range(len(collection)): 520 520 label_dict[collection[i]] = "%s %d" % (basename, i) 521 521 return label_dict … … 689 689 msg = "Plottable.View: Given x and dx are not" 690 690 msg += " of the same length" 691 raise ValueError , msg691 raise ValueError(msg) 692 692 # Check length of y array 693 693 if not len(y) == len(x): 694 694 msg = "Plottable.View: Given y " 695 695 msg += "and x are not of the same length" 696 raise ValueError , msg696 raise ValueError(msg) 697 697 698 698 if dy is not None and not len(dy) == 0 and not len(y) == len(dy): 699 699 msg = "Plottable.View: Given y and dy are not of the same " 700 700 msg += "length: len(y)=%s, len(dy)=%s" % (len(y), len(dy)) 701 raise ValueError , msg701 raise ValueError(msg) 702 702 self.x = [] 703 703 self.y = [] … … 734 734 msg = "Plottable.View: transformed x " 735 735 msg += "and y are not of the same length" 736 raise ValueError , msg736 raise ValueError(msg) 737 737 if has_err_x and not (len(self.x) == len(self.dx)): 738 738 msg = "Plottable.View: transformed x and dx" 739 739 msg += " are not of the same length" 740 raise ValueError , msg740 raise ValueError(msg) 741 741 if has_err_y and not (len(self.y) == len(self.dy)): 742 742 msg = "Plottable.View: transformed y" 743 743 msg += " and dy are not of the same length" 744 raise ValueError , msg744 raise ValueError(msg) 745 745 # Check that negative values are not plot on x and y axis for 746 746 # log10 transformation … … 814 814 except: 815 815 logger.error("check_data_logX: skipping point x %g", self.x[i]) 816 logger.error(sys.exc_ value)816 logger.error(sys.exc_info()[1]) 817 817 self.x = tempx 818 818 self.y = tempy … … 844 844 except: 845 845 logger.error("check_data_logY: skipping point %g", self.y[i]) 846 logger.error(sys.exc_ value)846 logger.error(sys.exc_info()[1]) 847 847 848 848 self.x = tempx … … 1108 1108 Plottable.__init__(self) 1109 1109 msg = "Theory1D is no longer supported, please use Data1D and change symbol.\n" 1110 raise DeprecationWarning , msg1110 raise DeprecationWarning(msg) 1111 1111 1112 1112 class Fit1D(Plottable): -
src/sas/sasgui/plottools/transform.py
- Property mode changed from 100644 to 100755
r7432acb rfa81e94 24 24 """ 25 25 if not x > 0: 26 raise ValueError , "Transformation only accepts positive values."26 raise ValueError("Transformation only accepts positive values.") 27 27 else: 28 28 return x … … 50 50 """ 51 51 if not x >= 0: 52 raise ValueError , "square root of a negative value "52 raise ValueError("square root of a negative value ") 53 53 else: 54 54 return math.sqrt(x) … … 76 76 """ 77 77 if not x >= 0: 78 raise ValueError , "double square root of a negative value "78 raise ValueError("double square root of a negative value ") 79 79 else: 80 80 return math.sqrt(math.sqrt(x)) … … 90 90 """ 91 91 if not x > 0: 92 raise ValueError , "Log(x)of a negative value "92 raise ValueError("Log(x)of a negative value ") 93 93 else: 94 94 return math.log(x) … … 100 100 return 1 / x 101 101 else: 102 raise ValueError , "cannot divide by zero"102 raise ValueError("cannot divide by zero") 103 103 104 104 … … 109 109 return 1 / math.sqrt(y) 110 110 else: 111 raise ValueError , "transform.toOneOverSqrtX: cannot be computed"111 raise ValueError("transform.toOneOverSqrtX: cannot be computed") 112 112 113 113 … … 118 118 return math.log(y * (x ** 2)) 119 119 else: 120 raise ValueError , "transform.toLogYX2: cannot be computed"120 raise ValueError("transform.toLogYX2: cannot be computed") 121 121 122 122 … … 127 127 return math.log(math.pow(x, 4) * y) 128 128 else: 129 raise ValueError , "transform.toLogYX4: input error"129 raise ValueError("transform.toLogYX4: input error") 130 130 131 131 … … 149 149 """ 150 150 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 ") 152 152 else: 153 153 return math.log(x * y) … … 211 211 else: 212 212 msg = "transform.errFromX2: can't compute error of negative x" 213 raise ValueError , msg213 raise ValueError(msg) 214 214 215 215 … … 245 245 else: 246 246 msg = "transform.errFromX4: can't compute error of negative x" 247 raise ValueError , msg247 raise ValueError(msg) 248 248 249 249 … … 264 264 msg = "Transformation does not accept" 265 265 msg += " point that are consistent with zero." 266 raise ValueError , msg266 raise ValueError(msg) 267 267 if x != 0: 268 268 dx = dx / (x * math.log(10)) 269 269 else: 270 raise ValueError , "errToLogX: divide by zero"270 raise ValueError("errToLogX: divide by zero") 271 271 return dx 272 272 … … 287 287 dx = dx / x 288 288 else: 289 raise ValueError , "errToLogX: divide by zero"289 raise ValueError("errToLogX: divide by zero") 290 290 return dx 291 291 … … 312 312 msg = "Transformation does not accept point " 313 313 msg += " that are consistent with zero." 314 raise ValueError , msg314 raise ValueError(msg) 315 315 if x != 0 and y != 0: 316 316 if dx is None: … … 320 320 err = (dx / x) ** 2 + (dy / y) ** 2 321 321 else: 322 raise ValueError , "cannot compute this error"322 raise ValueError("cannot compute this error") 323 323 324 324 return math.sqrt(math.fabs(err)) … … 335 335 msg = "Transformation does not accept point" 336 336 msg += " that are consistent with zero." 337 raise ValueError , msg337 raise ValueError(msg) 338 338 if x > 0 and y > 0: 339 339 if dx is None: … … 343 343 err = (2.0 * dx / x) ** 2 + (dy / y) ** 2 344 344 else: 345 raise ValueError , "cannot compute this error"345 raise ValueError("cannot compute this error") 346 346 return math.sqrt(math.fabs(err)) 347 347 … … 357 357 err = dx / x ** 2 358 358 else: 359 raise ValueError , "Cannot compute this error"359 raise ValueError("Cannot compute this error") 360 360 return math.fabs(err) 361 361 … … 371 371 err = -1 / 2 * math.pow(x, -3.0 / 2.0) * dx 372 372 else: 373 raise ValueError , "Cannot compute this error"373 raise ValueError("Cannot compute this error") 374 374 return math.fabs(err) 375 375 … … 387 387 msg = "Transformation does not accept point " 388 388 msg += " that are consistent with zero." 389 raise ValueError , msg389 raise ValueError(msg) 390 390 if dx is None: 391 391 dx = 0
Note: See TracChangeset
for help on using the changeset viewer.