Index: build_tools/pylint.rc
===================================================================
--- build_tools/pylint.rc	(revision dca618874c23dd325d1873dfec8151824084fba8)
+++ build_tools/pylint.rc	(revision 2df0b74178c150a9f521d5b09abf522c0578e825)
@@ -98,5 +98,5 @@
 
 # Good variable names which should always be accepted, separated by a comma
-good-names=i,j,k,ex,Run,_,x,y,z,qx,qy,qz,n,q,dx,dy,dz,id,Iq,dIq,Qx,Qy,Qz,ix,iy,iz
+good-names=i,j,k,ex,Run,_,x,y,z,qx,qy,qz,n,q,dx,dy,dz,id,Iq,dIq,Qx,Qy,Qz,ix,iy,iz,nx,ny,nz,getParam,setParam,runXY
 
 # Bad variable names which should always be refused, separated by a comma
Index: src/sas/plottools/BaseInteractor.py
===================================================================
--- src/sas/plottools/BaseInteractor.py	(revision 794922220f2fb3b23dd08c648aabf87b4850596c)
+++ src/sas/plottools/BaseInteractor.py	(revision 2df0b74178c150a9f521d5b09abf522c0578e825)
@@ -9,11 +9,11 @@
 
 
-class _BaseInteractor:
+class _BaseInteractor(object):
     """
     Share some functions between the interface interactor and various layer
     interactors.
-    
+
     Individual interactors need the following functions:
-    
+
         save(ev)  - save the current state for later restore
         restore() - restore the old state
@@ -21,7 +21,7 @@
         moveend(ev) - end the drag event
         update() - draw the interactors
-        
+
     The following are provided by the base class:
-    
+
         connect_markers(markers) - register callbacks for all markers
         clear_markers() - remove all items in self.markers
@@ -32,12 +32,12 @@
         onDrag(ev) - mouse move: calls move() or restore()
         onKey(ev) - keyboard move: calls move() or restore()
-        
+
     Interactor attributes:
-    
+
         base  - model we are operating on
         axes  - axes holding the interactor
         color - color of the interactor in non-active state
         markers - list of handles for the interactor
-        
+
     """
     def __init__(self, base, axes, color='black'):
@@ -48,5 +48,5 @@
         self.color = color
         self.markers = []
-        
+
     def clear_markers(self):
         '''
@@ -63,15 +63,15 @@
         """
         pass
-    
+
     def restore(self, ev):
         """
         """
         pass
-    
+
     def move(self, x, y, ev):
         """
         """
         pass
-    
+
     def moveend(self, ev):
         """
@@ -108,5 +108,5 @@
         self.base.draw()
         return True
-            
+
     def onClick(self, ev):
         """
@@ -137,10 +137,10 @@
         self.base.update()
         return True
-    
+
     def onKey(self, ev):
         """
         Respond to keyboard events.  Arrow keys move the widget.  Escape
         restores it to the position before the last click.
-        
+
         Calls move() to update the state.  Calls restore() on escape.
         """
@@ -173,7 +173,7 @@
         px, py = ax.transData.inverse_xy_tup((x, y))
         if nudge:
-            nx, ny = ax.transData.xy_tup((px+0.2, py+0.2))
+            nx, ny = ax.transData.xy_tup((px + 0.2, py + 0.2))
         else:
-            nx, ny = ax.transData.xy_tup((px+1., py+1.))
-        dx, dy = nx-x, ny-y
+            nx, ny = ax.transData.xy_tup((px + 1., py + 1.))
+        dx, dy = nx - x, ny - y
         return dx, dy
Index: src/sas/plottools/LabelDialog.py
===================================================================
--- src/sas/plottools/LabelDialog.py	(revision 794922220f2fb3b23dd08c648aabf87b4850596c)
+++ src/sas/plottools/LabelDialog.py	(revision 2df0b74178c150a9f521d5b09abf522c0578e825)
@@ -7,40 +7,37 @@
     FONT_VARIANT = 1
     PNL_WIDTH = 300
-    
+
 class LabelDialog(wx.Dialog):
     def __init__(self, parent, id, title, label):
         wx.Dialog.__init__(self, parent, id, title, size=(PNL_WIDTH, 150))
 
-        #panel = wx.Panel(self, -1)
-        #Font
+        # Font
         self.SetWindowVariant(variant=FONT_VARIANT)
         mainbox = wx.BoxSizer(wx.VERTICAL)
         vbox = wx.BoxSizer(wx.VERTICAL)
         textbox = wx.BoxSizer(wx.HORIZONTAL)
-        
+
         text1 = "Enter a new title/label:"
-        msg = wx.StaticText(self, -1, text1,(30,15), style=wx.ALIGN_LEFT)
+        msg = wx.StaticText(self, -1, text1, (30, 15), style=wx.ALIGN_LEFT)
         msg.SetLabel(text1)
-        self.myTxtCtrl = wx.TextCtrl(self, -1, '', (200, 30))
-        self.myTxtCtrl.SetValue(str(label))
-        textbox.Add(self.myTxtCtrl, flag=wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 
-                 border=10, proportion=2)
+        self.label_ctrl = wx.TextCtrl(self, -1, '', (200, 30))
+        self.label_ctrl.SetValue(str(label))
+        textbox.Add(self.label_ctrl, flag=wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE,
+                    border=10, proportion=2)
         vbox.Add(msg, flag=wx.ALL, border=10, proportion=1)
-        vbox.Add(textbox, flag=wx.EXPAND|wx.TOP|wx.BOTTOM|wx.ADJUST_MINSIZE,
-                 border=5)
+        vbox.Add(textbox, flag=wx.EXPAND | wx.TOP | wx.BOTTOM | wx.ADJUST_MINSIZE, border=5)
         hbox = wx.BoxSizer(wx.HORIZONTAL)
-        okButton = wx.Button(self,wx.ID_OK, 'OK', size=(70, 25))
-        closeButton = wx.Button(self,wx.ID_CANCEL, 'Cancel', size=(70, 25))
-        
-        hbox.Add(okButton, wx.LEFT, 10)
+        ok_button = wx.Button(self, wx.ID_OK, 'OK', size=(70, 25))
+        close_button = wx.Button(self, wx.ID_CANCEL, 'Cancel', size=(70, 25))
+
+        hbox.Add(ok_button, wx.LEFT, 10)
         hbox.Add((20, 20))
-        hbox.Add(closeButton, wx.LEFT, 10)
+        hbox.Add(close_button, wx.LEFT, 10)
 
         mainbox.Add(vbox, flag=wx.LEFT, border=5)
-        mainbox.Add(wx.StaticLine(self), 0, wx.ALL|wx.EXPAND, 5)
-        mainbox.Add(hbox, flag=wx.CENTER, 
-                    border=20)
+        mainbox.Add(wx.StaticLine(self), 0, wx.ALL | wx.EXPAND, 5)
+        mainbox.Add(hbox, flag=wx.CENTER, border=20)
         self.SetSizer(mainbox)
-    
+
     def getText(self):
-        return self.myTxtCtrl.GetValue()
+        return self.label_ctrl.GetValue()
Index: src/sas/plottools/LineModel.py
===================================================================
--- src/sas/plottools/LineModel.py	(revision 794922220f2fb3b23dd08c648aabf87b4850596c)
+++ src/sas/plottools/LineModel.py	(revision 2df0b74178c150a9f521d5b09abf522c0578e825)
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-""" 
-Provide Line function (y= A + Bx) 
+"""
+Provide Line function (y= A + Bx)
 """
 
@@ -7,56 +7,58 @@
 
 class LineModel(object):
-    """ 
+    """
     Class that evaluates a linear model.
-    
+
     f(x) = A + Bx
-     
+
     List of default parameters:
     A = 0.0
-    B = 0.0 
+    B = 0.0
     """
-        
+
     def __init__(self):
         """ Initialization """
-        ## Name of the model
+        # # Name of the model
         self.name = "LineModel"
 
-        ## Define parameters
+        # # Define parameters
         self.params = {}
         self.params['A'] = 1.0
         self.params['B'] = 1.0
 
-        ## Parameter details [units, min, max]
+        # # Parameter details [units, min, max]
         self.details = {}
         self.details['A'] = ['', None, None]
         self.details['B'] = ['', None, None]
-               
+
     def getParam(self, name):
         """
+            Return parameter value
         """
         return self.params[name.upper()]
-    
+
     def setParam(self, name, value):
         """
+            Set parameter value
         """
         self.params[name.upper()] = value
-    
+
     def _line(self, x):
         """
         Evaluate the function
-        
+
         :param x: x-value
-        
+
         :return: function value
-        
+
         """
         return  self.params['A'] + (x * self.params['B'])
-    
-    def run(self, x = 0.0):
-        """ 
+
+    def run(self, x=0.0):
+        """
         Evaluate the model
-        
+
         :param x: simple value
-        
+
         :return: (Line value)
         """
@@ -65,17 +67,17 @@
                                 self._line(x[0] * math.sin(x[1]))
         elif x.__class__.__name__ == 'tuple':
-            msg  = "Tuples are not allowed as input to BaseComponent models"
+            msg = "Tuples are not allowed as input to BaseComponent models"
             raise ValueError, msg
         else:
             return self._line(x)
-   
-    def runXY(self, x = 0.0):
-        """ 
+
+    def runXY(self, x=0.0):
+        """
         Evaluate the model
-            
+
         :param x: simple value
-        
+
         :return: Line value
-        
+
         """
         if x.__class__.__name__ == 'list':
@@ -86,7 +88,2 @@
         else:
             return self._line(x)
-   
-
-if __name__ == "__main__": 
-    l = Line()
-
Index: src/sas/plottools/arrow3d.py
===================================================================
--- src/sas/plottools/arrow3d.py	(revision 794922220f2fb3b23dd08c648aabf87b4850596c)
+++ src/sas/plottools/arrow3d.py	(revision 2df0b74178c150a9f521d5b09abf522c0578e825)
@@ -6,21 +6,21 @@
 from mpl_toolkits.mplot3d import proj3d
 import time
-#from matplotlib.artist import allow_rasterization
+# from matplotlib.artist import allow_rasterization
 class Arrow3D(FancyArrowPatch):
     """
     Draw 3D arrow
     """
-    
+
     def __init__(self, base, xs, ys, zs, colors, *args, **kwargs):
         """
         Init
-            
+
         :Params xs: [[x0, x0+dx0], [x1, x1+dx1], ...]
         :Params ys: [[y0, y0+dy0], [y1, y1+dy1], ...]
         :Params zs: [[z0, z0+dz0], [z1, z1+dz1], ...]
-        :Params colors: [[R0, G0, B0], [R1, G1, B1], ...] 
+        :Params colors: [[R0, G0, B0], [R1, G1, B1], ...]
         where R, G, B ranges (0,1)
         """
-        FancyArrowPatch.__init__(self, (0,0), (0,0), *args, **kwargs)
+        FancyArrowPatch.__init__(self, (0, 0), (0, 0), *args, **kwargs)
         self.leftdown = False
         self.t_click = 0
@@ -28,18 +28,20 @@
         self.colors = colors
         self.base = base
-        
+
         if base != None:
             # To turn the updating off during dragging
-            base.canvas.mpl_connect('button_press_event', self.onLeftDown)
-            base.canvas.mpl_connect('button_release_event', self.onLeftUp)
-            
-    def onLeftDown(self, event):
+            base.canvas.mpl_connect('button_press_event', self.on_left_down)
+            base.canvas.mpl_connect('button_release_event', self.on_left_up)
+
+    def on_left_down(self, event):
         """
+            Mouse left-down event
         """
         self.leftdown = True
         self.t_click = time.time()
-        
-    def onLeftUp(self, event):
+
+    def on_left_up(self, event):
         """
+            Mouse left up event
         """
         t_up = time.time() - self.t_click
@@ -48,5 +50,5 @@
             self.leftdown = False
             self.base.canvas.draw()
-    
+
     def draw(self, renderer, rasterized=True):
         """
@@ -58,9 +60,8 @@
         xs3d, ys3d, zs3d = self._verts3d
         for i in xrange(len(xs3d)):
-            xs, ys, _ = proj3d.proj_transform(xs3d[i], ys3d[i], zs3d[i], 
-                                               renderer.M)
-            self.set_positions((xs[0],ys[0]),(xs[1],ys[1]))
+            xs, ys, _ = proj3d.proj_transform(xs3d[i], ys3d[i], zs3d[i], renderer.M)
+            self.set_positions((xs[0], ys[0]), (xs[1], ys[1]))
             self.set_color(self.colors[i])
             FancyArrowPatch.draw(self, renderer)
-            
+
         self.leftdown = False
Index: src/sas/plottools/binder.py
===================================================================
--- src/sas/plottools/binder.py	(revision 794922220f2fb3b23dd08c648aabf87b4850596c)
+++ src/sas/plottools/binder.py	(revision 2df0b74178c150a9f521d5b09abf522c0578e825)
@@ -3,7 +3,7 @@
 """
 import sys
-
-
-class Selection:
+import logging
+
+class Selection(object):
     """
     Store and compare selections.
@@ -11,22 +11,22 @@
     # TODO: We need some way to check in prop matches, preferably
     # TODO: without imposing structure on prop.
-        
+
     artist = None
     prop = {}
-    
+
     def __init__(self, artist=None, prop={}):
         self.artist, self.prop = artist, self.prop
-        
+
     def __eq__(self, other):
         return self.artist is other.artist
-    
+
     def __ne__(self, other):
         return self.artist is not other.artist
-    
+
     def __nonzero__(self):
         return self.artist is not None
 
 
-class BindArtist:
+class BindArtist(object):
     """
     """
@@ -41,10 +41,10 @@
     dclick_threshhold = 0.25
     _last_button, _last_time = None, 0
-    
+
     # Mouse/keyboard events we can bind to
     events = ['enter', 'leave', 'motion', 'click', 'dclick', 'drag', 'release',
-             'scroll', 'key', 'keyup']
+              'scroll', 'key', 'keyup']
     # TODO: Need our own event structure
-    
+
     def __init__(self, figure):
         canvas = figure.canvas
@@ -69,5 +69,5 @@
                 canvas.mpl_connect('key_release_event', self._onKeyRelease),
             ]
-            
+
         self._current = None
         self._actions = {}
@@ -75,10 +75,10 @@
         self.figure = figure
         self.clearall()
-        
+
     def clear(self, *artists):
         """
         self.clear(h1,h2,...)
             Remove connections for artists h1, h2, ...
-            
+
         Use clearall() to reset all connections.
         """
@@ -96,9 +96,9 @@
         if self._haskey.artist in artists:
             self._haskey = Selection()
-        
+
     def clearall(self):
         """
         Clear connections to all artists.
-        
+
         Use clear(h1,h2,...) to reset specific artists.
         """
@@ -121,6 +121,5 @@
             for cid in self._connections: self.canvas.mpl_disconnect(cid)
         except:
-            print "Error disconnection canvas: %s" % sys.exc_value
-            pass
+            logging.error("Error disconnection canvas: %s" % sys.exc_value)
         self._connections = []
 
@@ -130,8 +129,8 @@
     def __call__(self, trigger, artist, action):
         """Register a callback for an artist to a particular trigger event.
-        
+
         usage:
             self.connect(eventname,artist,action)
-    
+
         where:
             eventname is a string
@@ -153,5 +152,5 @@
             key: key pressed when mouse is on the artist
             keyrelease: key released for the artist
-    
+
         The event received by action has a number of attributes:
             name is the event name which was triggered
@@ -165,5 +164,5 @@
             details is a dictionary of artist specific details, such as the
                 id(s) of the point that were clicked.
-                
+
         When receiving an event, first check the modifier state to be
         sure it applies.  E.g., the callback for 'press' might be:
@@ -203,5 +202,5 @@
         if action not in self.events:
             raise ValueError, "Trigger expects " + ", ".join(self.events)
-        
+
         # Tag the event with modifiers
         for mod in ('alt', 'control', 'shift', 'meta'):
@@ -210,5 +209,5 @@
         setattr(ev, 'action', action)
         setattr(ev, 'prop', {})
-        
+
         # Fallback scheme.  If the event does not return false, pass to parent.
         processed = False
@@ -249,5 +248,5 @@
                 found.artist, found.prop = artist, prop
                 break
-        
+
         # TODO: how to check if prop is equal?
         if found != self._current:
@@ -257,5 +256,5 @@
 
         return found
-        
+
     def _onMotion(self, event):
         """
@@ -263,15 +262,15 @@
         other artists are invisible.
         """
-        ## Can't kill double-click on motion since Windows produces
-        ## spurious motion events.
-        #self._last_button = None
-        
+        # # Can't kill double-click on motion since Windows produces
+        # # spurious motion events.
+        # self._last_button = None
+
         # Dibs on the motion event for the clicked artist
         if self._hasclick:
             # Make sure the x,y data use the coordinate system of the
             # artist rather than the default axes coordinates.
-            
+
             transform = self._hasclick.artist.get_transform()
-            #x,y = event.xdata,event.ydata
+            # x,y = event.xdata,event.ydata
             x, y = event.x, event.y
             try:
@@ -279,15 +278,15 @@
                     x, y = transform.inverted().transform((x, y))
                 else:
-                    ## For interactive plottable apply transform is not working
-                    ## don't know why maybe marker definition
-                    ##transform ="CompositeGenericTransform" crash
+                    # # For interactive plottable apply transform is not working
+                    # # don't know why maybe marker definition
+                    # #transform ="CompositeGenericTransform" crash
                     pass
             except:
-                ## CRUFT matplotlib-0.91 support
-                ## exception for transform ="CompositeGenericTransform"
-                ## crashes also here
+                # # CRUFT matplotlib-0.91 support
+                # # exception for transform ="CompositeGenericTransform"
+                # # crashes also here
                 x, y = transform.inverse_xy_tup((x, y))
 
-            #event.xdata, event.ydata = x, y
+            # event.xdata, event.ydata = x, y
             self.trigger(self._hasclick, 'drag', event)
         else:
@@ -300,5 +299,5 @@
         """
         import time
-        
+
         # Check for double-click
         event_time = time.time()
@@ -310,5 +309,5 @@
         self._last_button = event.button
         self._last_time = event_time
-        
+
         # If an artist is already dragging, feed any additional button
         # presses to that artist.
@@ -320,5 +319,5 @@
         else:
             found = self._find_current(event)
-        #print "button %d pressed"%event.button
+        # print "button %d pressed"%event.button
         # Note: it seems like if "click" returns False then hasclick should
         # not be set.  The problem is that there are two reasons it can
@@ -355,5 +354,5 @@
         self.trigger(self._hasclick, 'release', event)
         self._hasclick = Selection()
-            
+
     def _onKey(self, event):
         """
@@ -377,5 +376,5 @@
         self.trigger(found, 'key', event)
         self._haskey = found
-    
+
     def _onKeyRelease(self, event):
         """
@@ -385,5 +384,5 @@
             setattr(self, event.key, False)
             return
-        
+
         if self._haskey:
             self.trigger(self._haskey, 'keyup', event)
Index: src/sas/plottools/canvas.py
===================================================================
--- src/sas/plottools/canvas.py	(revision 794922220f2fb3b23dd08c648aabf87b4850596c)
+++ src/sas/plottools/canvas.py	(revision 2df0b74178c150a9f521d5b09abf522c0578e825)
@@ -5,7 +5,6 @@
 import wx
 import sys
+import logging
 from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
-from matplotlib.backends.backend_wxagg import _convert_agg_to_wx_bitmap
-from matplotlib.backends.backend_agg import FigureCanvasAgg
 from matplotlib.backend_bases import MouseEvent, RendererBase
 from matplotlib.backends.backend_wx import GraphicsContextWx, PrintoutWx
@@ -48,11 +47,11 @@
     dc = self.GetDC()
     try:
-        (ppw, pph) = self.GetPPIPrinter()      # printer's pixels per in
+        (ppw, pph) = self.GetPPIPrinter()  # printer's pixels per in
     except:
         ppw = 1
         pph = 1
-    (pgw, pgh) = self.GetPageSizePixels()  # page size in pixels
-    (dcw, dch) = dc.GetSize()
-    (grw, grh) = self.canvas.GetSizeTuple()
+    (pgw, _) = self.GetPageSizePixels()  # page size in pixels
+    (dcw, _) = dc.GetSize()
+    (grw, _) = self.canvas.GetSizeTuple()
 
     # save current figure dpi resolution and bg color,
@@ -78,5 +77,5 @@
     page_scale = 1.0
     if self.IsPreview():
-        page_scale = float(dcw)/pgw
+        page_scale = float(dcw) / pgw
 
     # get margin in pixels = (margin in in) * (pixels/in)
@@ -97,9 +96,9 @@
             dc.DrawBitmap(self.canvas.bitmap, (0, 0))
         except:
-            pass
+            logging.error(sys.exc_value)
 
     # restore original figure  resolution
     self.canvas.figure.set_facecolor(bgcolor)
-    ## used to be self.canvas.figure.dpi.set( fig_dpi)
+    # # used to be self.canvas.figure.dpi.set( fig_dpi)
     self.canvas.figure.dpi = fig_dpi
     self.canvas.draw()
@@ -121,5 +120,5 @@
         super(FigureCanvas, self).__init__(*args, **kw)
         self._isRendered = False
-        
+
         # Create an timer for handling draw_idle requests
         # If there are events pending when the timer is
@@ -136,5 +135,5 @@
         # Support for mouse wheel
         self.Bind(wx.EVT_MOUSEWHEEL, self._onMouseWheel)
-       
+
     def set_panel(self, panel):
         """
@@ -146,5 +145,5 @@
         self.xaxis = panel.subplot.xaxis
         self.yaxis = panel.subplot.yaxis
-        
+
     def draw_idle(self, *args, **kwargs):
         """
@@ -165,5 +164,5 @@
             self.draw(*args, **kwargs)
             self.resizing = False
-            
+
     def _get_axes_switch(self):
         """
@@ -184,5 +183,5 @@
         # set the resizing back to default= False
         self.set_resizing(False)
-        
+
     def set_resizing(self, resizing=False):
         """
@@ -191,5 +190,5 @@
         self.resizing = resizing
         self.panel.set_resizing(False)
-             
+
     def draw(self, drawDC=None):
         """
@@ -203,22 +202,19 @@
             self._isRendered = True
             self._get_axes_switch()
-            #import time
-            #st = time.time()
+            # import time
+            # st = time.time()
             try:
                 fig.draw(self)
             except ValueError:
-                pass
-            #self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None)
-            #self.gui_repaint(drawDC=drawDC)
-            #print "time", time.time() - st
+                logging.error(sys.exc_value)
         else:
             self._isRendered = False
         if self.ndraw <= 1:
             self.ndraw += 1
-        
+
     def _onMouseWheel(self, evt):
         """Translate mouse wheel events into matplotlib events"""
         # Determine mouse location
-        w, h = self.figure.canvas.get_width_height()
+        _, h = self.figure.canvas.get_width_height()
         x = evt.GetX()
         y = h - evt.GetY()
@@ -228,5 +224,5 @@
         rotation = evt.GetWheelRotation()
         rate = evt.GetLinesPerAction()
-        #print "delta,rotation,rate",delta,rotation,rate
+        # print "delta,rotation,rate",delta,rotation,rate
         step = rate * float(rotation) / delta
 
@@ -249,12 +245,12 @@
         if step != 0:
             self.panel.is_zoomed = True
-               
+
     def _onRightButtonDown(self, evt):
         """
         Overload the right button down call back to avoid a problem
         with the context menu over matplotlib plots on linux.
-        
+
         :TODO: Investigate what the root cause of the problem is.
-        
+
         """
         if sys.platform == 'linux2' or self.panel.dimension == 3:
@@ -271,3 +267,3 @@
     def _onLeave(self, evt):
         if self.HasCapture(): self.ReleaseMouse()
-        super(FigureCanvas,self)._onLeave(evt)
+        super(FigureCanvas, self)._onLeave(evt)
Index: src/sas/plottools/fitDialog.py
===================================================================
--- src/sas/plottools/fitDialog.py	(revision b9a5f0eb8e8cbff8f8d934bbfa4ea18168141e13)
+++ src/sas/plottools/fitDialog.py	(revision 2df0b74178c150a9f521d5b09abf522c0578e825)
@@ -7,5 +7,5 @@
 import sys
 
-#Linear fit panel size 
+# Linear fit panel size
 if sys.platform.count("win32") > 0:
     FONT_VARIANT = 0
@@ -16,6 +16,6 @@
     PNL_WIDTH = 500
     PNL_HEIGHT = 500
-RG_ON = True    
-    
+RG_ON = True
+
 def format_number(value, high=False):
     """
@@ -27,8 +27,8 @@
         output = "NaN"
         return output.lstrip().rstrip()
-    
+
     if high:
         output = "%-6.4g" % value
-        
+
     else:
         output = "%-5.3g" % value
@@ -42,42 +42,42 @@
         Displays fitting parameters
         """
-        wx.Dialog.__init__(self, parent, title=title, 
+        wx.Dialog.__init__(self, parent, title=title,
                            size=(PNL_WIDTH, 350))
         self.parent = parent
         self.transform = transform
-        #Font
+        # Font
         self.SetWindowVariant(variant=FONT_VARIANT)
         # Registered owner for close event
         self._registered_close = None
-        
-        #dialog panel self call function to plot the fitting function
+
+        # dialog panel self call function to plot the fitting function
         self.push_data = push_data
-        #dialog self plottable
+        # dialog self plottable
         self.plottable = plottable
         self.rg_on = False
         # Receive transformations of x and y
-        self.xLabel, self.yLabel, self.Avalue, self.Bvalue,\
+        self.xLabel, self.yLabel, self.Avalue, self.Bvalue, \
                self.ErrAvalue, self.ErrBvalue, self.Chivalue = self.transform()
-        
-        #Dialog interface
-        vbox  = wx.BoxSizer(wx.VERTICAL)
+
+        # Dialog interface
+        vbox = wx.BoxSizer(wx.VERTICAL)
         sizer = wx.GridBagSizer(5, 5)
         _BOX_WIDTH = 100
- 
-        self.tcA      = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20))
+
+        self.tcA = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20))
         self.tcA.SetToolTipString("Fit value for the slope parameter.")
-        self.tcErrA   = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20))
+        self.tcErrA = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20))
         self.tcErrA.SetToolTipString("Error on the slope parameter.")
-        self.tcB      = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20))
+        self.tcB = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20))
         self.tcA.SetToolTipString("Fit value for the constant parameter.")
-        self.tcErrB   = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20))
+        self.tcErrB = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20))
         self.tcErrB.SetToolTipString("Error on the constant parameter.")
-        self.tcChi    = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20))
+        self.tcChi = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20))
         self.tcChi.SetToolTipString("Chi^2 over degrees of freedom.")
-        self.xminFit  = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20))
+        self.xminFit = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20))
         msg = "Enter the minimum value on "
         msg += "the x-axis to be included in the fit."
         self.xminFit.SetToolTipString(msg)
-        self.xmaxFit  = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20))
+        self.xmaxFit = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20))
         msg = "Enter the maximum value on "
         msg += " the x-axis to be included in the fit."
@@ -91,5 +91,5 @@
 
         # Make the info box not editable
-        #_BACKGROUND_COLOR = '#ffdf85'
+        # _BACKGROUND_COLOR = '#ffdf85'
         _BACKGROUND_COLOR = self.GetBackgroundColour()
         self.initXmin.SetEditable(False)
@@ -97,5 +97,5 @@
         self.initXmax.SetEditable(False)
         self.initXmax.SetBackgroundColour(_BACKGROUND_COLOR)
-        
+
         # Buttons on the bottom
         self.bg_on = False
@@ -104,5 +104,5 @@
         self.btFit.Bind(wx.EVT_BUTTON, self._onFit)
         self.btFit.SetToolTipString("Perform fit.")
-        self.btClose =wx.Button(self, wx.ID_CANCEL, 'Close')
+        self.btClose = wx.Button(self, wx.ID_CANCEL, 'Close')
         self.btClose.Bind(wx.EVT_BUTTON, self._on_close)
         if RG_ON:
@@ -122,67 +122,64 @@
         iy = 1
         sizer.Add(wx.StaticText(self, -1, explanation), (iy, ix),
-                 (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+                  (1, 1), wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
         iy += 2
         sizer.Add(wx.StaticText(self, -1, param_a), (iy, ix),
-                 (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        ix += 1
-        sizer.Add(self.tcA,(iy, ix),(1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+                  (1, 1), wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
+        ix += 1
+        sizer.Add(self.tcA, (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         ix += 1
         sizer.Add(wx.StaticText(self, -1, '+/-'),
-                  (iy, ix), (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+                  (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         ix += 1
         sizer.Add(self.tcErrA, (iy, ix), (1, 1),
-                  wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+                  wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         iy += 1
         ix = 0
-        sizer.Add(wx.StaticText(self, -1, 'Parameter b'), (iy, ix),(1, 1),
-                   wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        ix += 1
-        sizer.Add(self.tcB, (iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        sizer.Add(wx.StaticText(self, -1, 'Parameter b'), (iy, ix), (1, 1),
+                  wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
+        ix += 1
+        sizer.Add(self.tcB, (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         ix += 1
         sizer.Add(wx.StaticText(self, -1, '+/-'), (iy, ix),
-                  (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+                  (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         ix += 1
         sizer.Add(self.tcErrB, (iy, ix), (1, 1),
-                   wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+                  wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         iy += 1
         ix = 0
         sizer.Add(wx.StaticText(self, -1, 'Chi2/dof'), (iy, ix), (1, 1),
-                   wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        ix += 1
-        sizer.Add(self.tcChi, (iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-
-        
-        #sizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
+                  wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
+        ix += 1
+        sizer.Add(self.tcChi, (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         iy += 2
         ix = 1
         sizer.Add(wx.StaticText(self, -1, 'Min'), (iy, ix), (1, 1),
-                   wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+                  wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         ix += 2
         sizer.Add(wx.StaticText(self, -1, 'Max'), (iy, ix),
-                  (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+                  (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0)
 
         iy += 1
         ix = 0
         sizer.Add(wx.StaticText(self, -1, 'Maximum range (linear scale)'),
-                  (iy, ix),(1,1),
-                   wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        ix += 1
-        sizer.Add(self.initXmin, (iy, ix), (1,1),
-                   wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+                  (iy, ix), (1, 1),
+                  wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
+        ix += 1
+        sizer.Add(self.initXmin, (iy, ix), (1, 1),
+                  wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         ix += 2
-        sizer.Add(self.initXmax, (iy, ix), (1,1), 
-                  wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-       
+        sizer.Add(self.initXmax, (iy, ix), (1, 1),
+                  wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+
         iy += 1
         ix = 0
         sizer.Add(wx.StaticText(self, -1, 'Fit range of ' + self.xLabel),
                   (iy, ix), (1, 1),
-                   wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+                  wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
         ix += 1
         sizer.Add(self.xminFit, (iy, ix), (1, 1),
-                   wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+                  wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         ix += 2
-        sizer.Add(self.xmaxFit, (iy, ix), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        sizer.Add(self.xmaxFit, (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         if self.rg_on:
             self.SetSize((PNL_WIDTH, PNL_HEIGHT))
@@ -195,15 +192,15 @@
             self.I0err_tctr.SetBackgroundColour(_BACKGROUND_COLOR)
             Rg_stxt = wx.StaticText(self, -1, 'Rg [A]')
-            Rg_stxt.Show(self.yLabel == "ln(y)" )
+            Rg_stxt.Show(self.yLabel == "ln(y)")
             self.Rg_tctr = wx.TextCtrl(self, -1, '')
             self.Rg_tctr.SetEditable(False)
             self.Rg_tctr.SetBackgroundColour(_BACKGROUND_COLOR)
-            self.Rg_tctr.Show(self.yLabel == "ln(y)" )
+            self.Rg_tctr.Show(self.yLabel == "ln(y)")
             self.Rgerr_tctr = wx.TextCtrl(self, -1, '')
             self.Rgerr_tctr.SetEditable(False)
             self.Rgerr_tctr.SetBackgroundColour(_BACKGROUND_COLOR)
-            self.Rgerr_tctr.Show(self.yLabel == "ln(y)" )
+            self.Rgerr_tctr.Show(self.yLabel == "ln(y)")
             self.Rgerr_pm = wx.StaticText(self, -1, '+/-')
-            self.Rgerr_pm.Show(self.yLabel == "ln(y)" )
+            self.Rgerr_pm.Show(self.yLabel == "ln(y)")
             Diameter_stxt = wx.StaticText(self, -1, 'Rod Diameter [A]')
             Diameter_stxt.Show(self.yLabel == "ln(y*x)")
@@ -229,72 +226,72 @@
             iy += 2
             ix = 0
-            sizer.Add(I0_stxt, (iy, ix), (1,1),
-                                    wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-            ix += 1
-            sizer.Add(self.I0_tctr, (iy, ix), (1,1),
-                                    wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+            sizer.Add(I0_stxt, (iy, ix), (1, 1),
+                      wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
+            ix += 1
+            sizer.Add(self.I0_tctr, (iy, ix), (1, 1),
+                      wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 0)
             ix += 1
             sizer.Add(wx.StaticText(self, -1, '+/-'), (iy, ix),
-                                    (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-            ix += 1
-            sizer.Add(self.I0err_tctr, (iy, ix), (1,1), 
-                                    wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-            
+                      (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+            ix += 1
+            sizer.Add(self.I0err_tctr, (iy, ix), (1, 1),
+                      wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+
             iy += 1
             ix = 0
-            sizer.Add(Rg_stxt, (iy, ix),(1,1),
-                                    wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-            ix += 1
-            sizer.Add(self.Rg_tctr, (iy, ix), (1,1),
-                                    wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-    
+            sizer.Add(Rg_stxt, (iy, ix), (1, 1),
+                      wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
+            ix += 1
+            sizer.Add(self.Rg_tctr, (iy, ix), (1, 1),
+                      wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+
             ix += 1
             sizer.Add(self.Rgerr_pm, (iy, ix),
-                                    (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-            ix += 1
-            sizer.Add(self.Rgerr_tctr, (iy, ix), (1,1), 
-                                    wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+                      (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+            ix += 1
+            sizer.Add(self.Rgerr_tctr, (iy, ix), (1, 1),
+                      wx.EXPAND | wx.ADJUST_MINSIZE, 0)
             iy += 1
             ix = 0
-            sizer.Add(Diameter_stxt, (iy, ix),(1,1),
-                                    wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-            ix += 1
-            sizer.Add(self.Diameter_tctr, (iy, ix), (1,1),
-                                    wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-    
+            sizer.Add(Diameter_stxt, (iy, ix), (1, 1),
+                      wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
+            ix += 1
+            sizer.Add(self.Diameter_tctr, (iy, ix), (1, 1),
+                      wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+
             ix += 1
             sizer.Add(self.Diameter_pm, (iy, ix),
-                                    (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-            ix += 1
-            sizer.Add(self.Diametererr_tctr, (iy, ix), (1,1), 
-                                    wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+                      (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+            ix += 1
+            sizer.Add(self.Diametererr_tctr, (iy, ix), (1, 1),
+                      wx.EXPAND | wx.ADJUST_MINSIZE, 0)
             iy += 1
             ix = 0
-            sizer.Add(RgQmin_stxt, (iy, ix),(1,1),
-                                    wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-            ix += 1
-            sizer.Add(self.RgQmin_tctr, (iy, ix), (1,1),
-                                    wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+            sizer.Add(RgQmin_stxt, (iy, ix), (1, 1),
+                      wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
+            ix += 1
+            sizer.Add(self.RgQmin_tctr, (iy, ix), (1, 1),
+                      wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 0)
             iy += 1
             ix = 0
-            sizer.Add(RgQmax_stxt, (iy, ix),(1,1),
-                                    wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-            ix += 1
-            sizer.Add(self.RgQmax_tctr, (iy, ix), (1,1),
-                                    wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-            
+            sizer.Add(RgQmax_stxt, (iy, ix), (1, 1),
+                      wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
+            ix += 1
+            sizer.Add(self.RgQmax_tctr, (iy, ix), (1, 1),
+                      wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+
         iy += 1
         ix = 1
-        
+
         vbox.Add(self.static_line_1, 0, wx.EXPAND, 0)
         sizer_button = wx.BoxSizer(wx.HORIZONTAL)
-        sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        sizer_button.Add(self.btFit, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)
+        sizer_button.Add((20, 20), 1, wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+        sizer_button.Add(self.btFit, 0, wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10)
         sizer_button.Add(self.btClose, 0,
-                          wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)
-        vbox.Add(sizer_button, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
-        
-        sizer.Add(self.btFit, (iy, ix), (1,1), wx.LEFT|wx.ADJUST_MINSIZE, 0)
-        #panel.SetSizer(sizer)
+                         wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10)
+        vbox.Add(sizer_button, 0, wx.EXPAND | wx.BOTTOM | wx.TOP, 10)
+
+        sizer.Add(self.btFit, (iy, ix), (1, 1), wx.LEFT | wx.ADJUST_MINSIZE, 0)
+        # panel.SetSizer(sizer)
         self.SetSizer(vbox)
         self.Centre()
@@ -302,10 +299,10 @@
         from LineModel import LineModel
         self.model = LineModel()
-        #Display the fittings values
+        # Display the fittings values
         self.default_A = self.model.getParam('A')
         self.default_B = self.model.getParam('B')
         self.cstA = fittings.Parameter(self.model, 'A', self.default_A)
         self.cstB = fittings.Parameter(self.model, 'B', self.default_B)
-        
+
         # Set default value of parameter in fit dialog
         if self.Avalue == None:
@@ -330,5 +327,5 @@
             self.tcChi.SetLabel(format_number(self.Chivalue))
         if self.plottable.x != []:
-            #store the values of View in self.x,self.y,self.dx,self.dy
+            # store the values of View in self.x,self.y,self.dx,self.dy
             self.x, self.y, self.dx, \
                      self.dy = self.plottable.returnValuesOfView()
@@ -348,5 +345,5 @@
             self.xminFit.SetValue(format_number(self.mini))
             self.xmaxFit.SetValue(format_number(self.maxi))
-    
+
     def register_close(self, owner):
         """
@@ -354,10 +351,10 @@
         window that needs notification when the dialog
         is closed
-        
+
         :param owner: parent window
-        
+
         """
         self._registered_close = owner
-        
+
     def _on_close(self, event):
         """
@@ -368,5 +365,5 @@
         if self._registered_close is not None:
             self._registered_close()
-        
+
     def _onFit(self, event):
         """
@@ -379,19 +376,15 @@
         tempy = []
         tempdy = []
-            
+
         # Check if View contains a x array .we online fit when x exits
         # makes transformation for y as a line to fit
         if self.x != []:
-            if(self.checkFitValues(self.xminFit) == True):
-                #Check if the field of Fit Dialog contain values
+            if self.checkFitValues(self.xminFit) == True:
+                # Check if the field of Fit Dialog contain values
                 # and use the x max and min of the user
-                #xminView,xmaxView = self._checkVal(self.xminFit.GetValue(),
-                #self.xmaxFit.GetValue())
                 if not self._checkVal(self.xminFit, self.xmaxFit):
                     return
                 xminView = float(self.xminFit.GetValue())
                 xmaxView = float(self.xmaxFit.GetValue())
-                #xmin = self.floatInvTransform(xminView)
-                #xmax = self.floatInvTransform(xmaxView)
                 xmin = xminView
                 xmax = xmaxView
@@ -399,20 +392,18 @@
                 # in variables  before the fit
                 if self.yLabel.lower() == "log10(y)":
-                    if (self.xLabel.lower() == "log10(x)"):
+                    if self.xLabel.lower() == "log10(x)":
                         for i in range(len(self.x)):
                             if self.x[i] >= math.log10(xmin):
                                 tempy.append(math.log10(self.y[i]))
-                                tempdy.append(transform.errToLogX(self.y[i],
-                                                        0, self.dy[i], 0))
+                                tempdy.append(transform.errToLogX(self.y[i], 0, self.dy[i], 0))
                     else:
                         for i in range(len(self.y)):
                             tempy.append(math.log10(self.y[i]))
-                            tempdy.append(transform.errToLogX(self.y[i],
-                                                            0, self.dy[i], 0))
+                            tempdy.append(transform.errToLogX(self.y[i], 0, self.dy[i], 0))
                 else:
                     tempy = self.y
                     tempdy = self.dy
-               
-                if (self.xLabel.lower() == "log10(x)"):
+
+                if self.xLabel.lower() == "log10(x)":
                     for x_i in self.x:
                         if x_i >= math.log10(xmin):
@@ -420,32 +411,32 @@
                 else:
                     tempx = self.x
-              
-                #Find the fitting parameters
+
+                # Find the fitting parameters
                 # Always use the same defaults, so that fit history
-                #doesn't play a role!
+                # doesn't play a role!
                 self.cstA = fittings.Parameter(self.model, 'A', self.default_A)
                 self.cstB = fittings.Parameter(self.model, 'B', self.default_B)
-                
-                if (self.xLabel.lower() == "log10(x)"):
+
+                if self.xLabel.lower() == "log10(x)":
                     tempdy = numpy.asarray(tempdy)
                     tempdy[tempdy == 0] = 1
                     chisqr, out, cov = fittings.sasfit(self.model,
-                                                        [self.cstA, self.cstB],
-                                                        tempx, tempy,
-                                                        tempdy,
-                                                        math.log10(xmin),
-                                                        math.log10(xmax))
+                                                       [self.cstA, self.cstB],
+                                                       tempx, tempy,
+                                                       tempdy,
+                                                       math.log10(xmin),
+                                                       math.log10(xmax))
                 else:
                     tempdy = numpy.asarray(tempdy)
                     tempdy[tempdy == 0] = 1
                     chisqr, out, cov = fittings.sasfit(self.model,
-                                                        [self.cstA, self.cstB],
-                                                        tempx, tempy, tempdy,
-                                                        xminView, xmaxView)
+                                                       [self.cstA, self.cstB],
+                                                       tempx, tempy, tempdy,
+                                                       xminView, xmaxView)
                 # Use chi2/dof
                 if len(tempx) > 0:
-                    chisqr = chisqr/len(tempx)
-                
-                #Check that cov and out are iterable before displaying them
+                    chisqr = chisqr / len(tempx)
+
+                # Check that cov and out are iterable before displaying them
                 if cov == None:
                     errA = 0.0
@@ -463,10 +454,10 @@
                 self.model.setParam('A', float(cstA))
                 self.model.setParam('B', float(cstB))
-                
+
                 tempx = []
                 tempy = []
                 y_model = 0.0
                 # load tempy with the minimum transformation
-               
+
                 if self.xLabel == "log10(x)":
                     y_model = self.model.run(math.log10(xmin))
@@ -475,10 +466,10 @@
                     y_model = self.model.run(xminView)
                     tempx.append(xminView)
-                    
+
                 if self.yLabel == "log10(y)":
                     tempy.append(math.pow(10, y_model))
                 else:
                     tempy.append(y_model)
-                    
+
                 # load tempy with the maximum transformation
                 if self.xLabel == "log10(x)":
@@ -488,10 +479,10 @@
                     y_model = self.model.run(xmaxView)
                     tempx.append(xmaxView)
-                    
+
                 if self.yLabel == "log10(y)":
                     tempy.append(math.pow(10, y_model))
                 else:
                     tempy.append(y_model)
-                #Set the fit parameter display when  FitDialog is opened again
+                # Set the fit parameter display when  FitDialog is opened again
                 self.Avalue = cstB
                 self.Bvalue = cstA
@@ -501,8 +492,8 @@
                 self.push_data(tempx, tempy, xminView, xmaxView,
                                xmin, xmax, self._ongetValues())
-                
+
                 # Display the fitting value on the Fit Dialog
                 self._onsetValues(cstB, cstA, errA, errB, chisqr)
-               
+
     def _onsetValues(self, cstA, cstB, errA, errB, Chi):
         """
@@ -527,5 +518,5 @@
                     value = format_number(3 * float(cstA) / (2 * rg))
                 else:
-                    value =''
+                    value = ''
                 self.Rgerr_tctr.SetValue(value)
                 if self.I0err_tctr.IsShown():
@@ -540,5 +531,5 @@
                     value = format_number(8 * float(cstA) / rg)
                 else:
-                    value =''
+                    value = ''
                 self.Diametererr_tctr.SetValue(value)
             if self.RgQmin_tctr.IsShown():
@@ -548,5 +539,5 @@
                 value = format_number(rg * self.maxi)
                 self.RgQmax_tctr.SetValue(value)
-                
+
     def _ongetValues(self):
         """
@@ -555,5 +546,5 @@
         return self.Avalue, self.Bvalue, self.ErrAvalue, \
                             self.ErrBvalue, self.Chivalue
-    
+
     def _checkVal(self, usermin, usermax):
         """
@@ -579,22 +570,22 @@
             usermin.SetBackgroundColour("pink")
             usermin.Refresh()
-      
+
         return flag
-            
+
     def floatForwardTransform(self, x):
         """
         transform a float.
         """
-        #TODO: refactor this with proper object-oriented design
+        # TODO: refactor this with proper object-oriented design
         # This code stinks.
-        if(self.xLabel == "x"):
+        if self.xLabel == "x":
             return transform.toX(x)
-        if(self.xLabel == "x^(2)"):
+        if self.xLabel == "x^(2)":
             return transform.toX2(x)
-        if(self.xLabel == "ln(x)"):
+        if self.xLabel == "ln(x)":
             return transform.toLogX(x)
-        if(self.xLabel == "log10(x)"):
+        if self.xLabel == "log10(x)":
             return math.log10(x)
-                    
+
     def floatTransform(self, x):
         """
@@ -603,37 +594,35 @@
         not in x
         """
-        #TODO: refactor this with proper object-oriented design
+        # TODO: refactor this with proper object-oriented design
         # This code stinks.
-        if(self.xLabel == "x"):
+        if self.xLabel == "x":
             return transform.toX(x)
-        if(self.xLabel == "x^(2)"):
+        if self.xLabel == "x^(2)":
             return transform.toX2(x)
-        if(self.xLabel == "ln(x)"):
+        if self.xLabel == "ln(x)":
             return transform.toLogX(x)
-        if(self.xLabel == "log10(x)"):
+        if self.xLabel == "log10(x)":
             if x > 0:
                 return x
             else:
                 raise ValueError, "cannot compute log of a negative number"
-            
+
     def floatInvTransform(self, x):
         """
         transform a float.It is use to determine the x.View min and x.View
         max for values not in x
-        
-        """
-        #TODO: refactor this. This is just a hack to make the
+
+        """
+        # TODO: refactor this. This is just a hack to make the
         # functionality work without rewritting the whole code
         # with good design (which really should be done...).
-        if(self.xLabel == "x^(2)"):
+        if self.xLabel == "x^(2)":
             return math.sqrt(x)
-        
-        elif(self.xLabel == "log10(x)"):
+        elif self.xLabel == "log10(x)":
             return math.pow(10, x)
-        
-        elif(self.xLabel == "ln(x)"):
+        elif self.xLabel == "ln(x)":
             return math.exp(x)
         return x
-            
+
     def checkFitValues(self, item):
         """
@@ -643,6 +632,6 @@
         value = item.GetValue()
         # Check for possible values entered
-        if (self.xLabel == "log10(x)"):  #or self.xLabel=="ln(x)"):
-            if(float(value) > 0):
+        if self.xLabel == "log10(x)":
+            if float(value) > 0:
                 item.SetBackgroundColour(wx.WHITE)
                 item.Refresh()
@@ -652,5 +641,5 @@
                 item.Refresh()
         return flag
-       
+
     def setFitRange(self, xmin, xmax, xminTrans, xmaxTrans):
         """
@@ -659,5 +648,5 @@
         self.xminFit.SetValue(format_number(xmin))
         self.xmaxFit.SetValue(format_number(xmax))
-        
+
     def set_fit_region(self, xmin, xmax):
         """
@@ -675,11 +664,13 @@
         self.xminFit.SetValue(format_number(xmin))
         self.xmaxFit.SetValue(format_number(xmax))
-  
-  
+
+
 class MyApp(wx.App):
     """
+        Test application
     """
     def OnInit(self):
         """
+            Test application initialization
         """
         wx.InitAllImageHandlers()
@@ -688,17 +679,19 @@
                            push_data=self.onFitDisplay,
                            transform=self.returnTrans,
-                            title='Linear Fit')
+                           title='Linear Fit')
         if dialog.ShowModal() == wx.ID_OK:
             pass
         dialog.Destroy()
         return 1
-    
+
     def onFitDisplay(self, tempx, tempy, xminView, xmaxView, xmin, xmax, func):
         """
+            Test application dummy method
         """
         pass
-        
+
     def returnTrans(self):
         """
+            Test application dummy method
         """
         return '', '', 0, 0, 0, 0, 0
Index: src/sas/plottools/fittings.py
===================================================================
--- src/sas/plottools/fittings.py	(revision b9a5f0eb8e8cbff8f8d934bbfa4ea18168141e13)
+++ src/sas/plottools/fittings.py	(revision 2df0b74178c150a9f521d5b09abf522c0578e825)
@@ -4,14 +4,14 @@
 
 
-class Parameter:
+class Parameter(object):
     """
     Class to handle model parameters
     """
     def __init__(self, model, name, value=None):
-            self.model = model
-            self.name = name
-            if not value == None:
-                self.model.setParam(self.name, value)
-           
+        self.model = model
+        self.name = name
+        if not value == None:
+            self.model.setParam(self.name, value)
+
     def set(self, value):
         """
@@ -25,10 +25,10 @@
         """
         return self.model.getParam(self.name)
-    
-    
-def sasfit(model, pars, x, y, err_y , qmin=None, qmax=None):
+
+
+def sasfit(model, pars, x, y, err_y, qmin=None, qmax=None):
     """
     Fit function
-    
+
     :param model: sas model object
     :param pars: list of parameters
@@ -41,5 +41,5 @@
         Calculates the vector of residuals for each point
         in y for a given set of input parameters.
-        
+
         :param params: list of parameter values
         :return: vector of residuals
@@ -49,5 +49,5 @@
             p.set(params[i])
             i += 1
-        
+
         residuals = []
         for j in range(len(x)):
@@ -55,13 +55,13 @@
                 residuals.append((y[j] - model.runXY(x[j])) / err_y[j])
         return residuals
-        
+
     def chi2(params):
         """
         Calculates chi^2
-        
+
         :param params: list of parameter values
-        
+
         :return: chi^2
-        
+
         """
         sum = 0
@@ -70,5 +70,5 @@
             sum += item * item
         return sum
-        
+
     p = [param() for param in pars]
     out, cov_x, info, mesg, success = optimize.leastsq(f, p, full_output=1)
@@ -78,10 +78,10 @@
     elif len(pars) == 1:
         chisqr = chi2([out])
-        
+
     return chisqr, out, cov_x
 
 
 def calcCommandline(event):
-    #Testing implementation
+    # Testing implementation
     # Fit a Line model
     from LineModel import LineModel
