Index: src/sas/sascalc/dataloader/manipulations.py
===================================================================
--- src/sas/sascalc/dataloader/manipulations.py	(revision dd11014add466ed4ba0564fcf61e5880d53e6c8b)
+++ src/sas/sascalc/dataloader/manipulations.py	(revision fd5d6eac046494e899ed8c6951bb2e8900b24d0f)
@@ -5,14 +5,16 @@
 """
 #####################################################################
-#This software was developed by the University of Tennessee as part of the
-#Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-#project funded by the US National Science Foundation.
-#See the license text in license.txt
-#copyright 2008, University of Tennessee
+# This software was developed by the University of Tennessee as part of the
+# Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
+# project funded by the US National Science Foundation.
+# See the license text in license.txt
+# copyright 2008, University of Tennessee
 ######################################################################
 
-#TODO: copy the meta data from the 2D object to the resulting 1D object
+# If you want to run just a single test from this file:
+# PYTHONPATH=../src/ python2  -m sasdataloader.test.utest_averaging data_info_tests.test_sectorq_full
+# TODO: copy the meta data from the 2D object to the resulting 1D object
 import math
-import numpy
+import numpy as np
 
 #from data_info import plottable_2D
@@ -82,6 +84,6 @@
     if data2d.data is None or data2d.x_bins is None or data2d.y_bins is None:
         raise ValueError, "Can't convert this data: data=None..."
-    new_x = numpy.tile(data2d.x_bins, (len(data2d.y_bins), 1))
-    new_y = numpy.tile(data2d.y_bins, (len(data2d.x_bins), 1))
+    new_x = np.tile(data2d.x_bins, (len(data2d.y_bins), 1))
+    new_y = np.tile(data2d.y_bins, (len(data2d.x_bins), 1))
     new_y = new_y.swapaxes(0, 1)
 
@@ -89,12 +91,12 @@
     qx_data = new_x.flatten()
     qy_data = new_y.flatten()
-    q_data = numpy.sqrt(qx_data * qx_data + qy_data * qy_data)
-    if data2d.err_data is None or numpy.any(data2d.err_data <= 0):
-        new_err_data = numpy.sqrt(numpy.abs(new_data))
+    q_data = np.sqrt(qx_data * qx_data + qy_data * qy_data)
+    if data2d.err_data is None or np.any(data2d.err_data <= 0):
+        new_err_data = np.sqrt(np.abs(new_data))
     else:
         new_err_data = data2d.err_data.flatten()
-    mask = numpy.ones(len(new_data), dtype=bool)
-
-    #TODO: make sense of the following two lines...
+    mask = np.ones(len(new_data), dtype=bool)
+
+    # TODO: make sense of the following two lines...
     #from sas.sascalc.dataloader.data_info import Data2D
     #output = Data2D()
@@ -114,4 +116,5 @@
     Compute average I(Q) for a region of interest
     """
+
     def __init__(self, x_min=0.0, x_max=0.0, y_min=0.0,
                  y_max=0.0, bin_width=0.001):
@@ -149,8 +152,8 @@
 
         # Get data
-        data = data2D.data[numpy.isfinite(data2D.data)]
-        err_data = data2D.err_data[numpy.isfinite(data2D.data)]
-        qx_data = data2D.qx_data[numpy.isfinite(data2D.data)]
-        qy_data = data2D.qy_data[numpy.isfinite(data2D.data)]
+        data = data2D.data[np.isfinite(data2D.data)]
+        err_data = data2D.err_data[np.isfinite(data2D.data)]
+        qx_data = data2D.qx_data[np.isfinite(data2D.data)]
+        qy_data = data2D.qy_data[np.isfinite(data2D.data)]
 
         # Build array of Q intervals
@@ -170,8 +173,8 @@
             raise RuntimeError, "_Slab._avg: unrecognized axis %s" % str(maj)
 
-        x = numpy.zeros(nbins)
-        y = numpy.zeros(nbins)
-        err_y = numpy.zeros(nbins)
-        y_counts = numpy.zeros(nbins)
+        x = np.zeros(nbins)
+        y = np.zeros(nbins)
+        err_y = np.zeros(nbins)
+        y_counts = np.zeros(nbins)
 
         # Average pixelsize in q space
@@ -205,10 +208,10 @@
                 continue
 
-            #TODO: find better definition of x[i_q] based on q_data
+            # TODO: find better definition of x[i_q] based on q_data
             # min_value + (i_q + 1) * self.bin_width / 2.0
             x[i_q] += frac * q_value
             y[i_q] += frac * data[npts]
 
-            if err_data == None or err_data[npts] == 0.0:
+            if err_data is None or err_data[npts] == 0.0:
                 if data[npts] < 0:
                     data[npts] = -data[npts]
@@ -225,5 +228,5 @@
         y = y / y_counts
         x = x / y_counts
-        idx = (numpy.isfinite(y) & numpy.isfinite(x))
+        idx = (np.isfinite(y) & np.isfinite(x))
 
         if not idx.any():
@@ -237,4 +240,5 @@
     Compute average I(Qy) for a region of interest
     """
+
     def __call__(self, data2D):
         """
@@ -251,4 +255,5 @@
     Compute average I(Qx) for a region of interest
     """
+
     def __call__(self, data2D):
         """
@@ -264,4 +269,5 @@
     Perform the sum of counts in a 2D region of interest.
     """
+
     def __init__(self, x_min=0.0, x_max=0.0, y_min=0.0, y_max=0.0):
         # Minimum Qx value [A-1]
@@ -304,8 +310,8 @@
             raise RuntimeError, msg
         # Get data
-        data = data2D.data[numpy.isfinite(data2D.data)]
-        err_data = data2D.err_data[numpy.isfinite(data2D.data)]
-        qx_data = data2D.qx_data[numpy.isfinite(data2D.data)]
-        qy_data = data2D.qy_data[numpy.isfinite(data2D.data)]
+        data = data2D.data[np.isfinite(data2D.data)]
+        err_data = data2D.err_data[np.isfinite(data2D.data)]
+        qx_data = data2D.qx_data[np.isfinite(data2D.data)]
+        qy_data = data2D.qy_data[np.isfinite(data2D.data)]
 
         y = 0.0
@@ -328,10 +334,10 @@
             if self.y_min <= qy and self.y_max > qy:
                 frac_y = 1
-            #Find the fraction along each directions
+            # Find the fraction along each directions
             frac = frac_x * frac_y
             if frac == 0:
                 continue
             y += frac * data[npts]
-            if err_data == None or err_data[npts] == 0.0:
+            if err_data is None or err_data[npts] == 0.0:
                 if data[npts] < 0:
                     data[npts] = -data[npts]
@@ -347,4 +353,5 @@
     Perform the average of counts in a 2D region of interest.
     """
+
     def __init__(self, x_min=0.0, x_max=0.0, y_min=0.0, y_max=0.0):
         super(Boxavg, self).__init__(x_min=x_min, x_max=x_max,
@@ -398,4 +405,5 @@
     as a function of Q
     """
+
     def __init__(self, r_min=0.0, r_max=0.0, bin_width=0.0005):
         # Minimum radius included in the average [A-1]
@@ -414,8 +422,8 @@
         """
         # Get data W/ finite values
-        data = data2D.data[numpy.isfinite(data2D.data)]
-        q_data = data2D.q_data[numpy.isfinite(data2D.data)]
-        err_data = data2D.err_data[numpy.isfinite(data2D.data)]
-        mask_data = data2D.mask[numpy.isfinite(data2D.data)]
+        data = data2D.data[np.isfinite(data2D.data)]
+        q_data = data2D.q_data[np.isfinite(data2D.data)]
+        err_data = data2D.err_data[np.isfinite(data2D.data)]
+        mask_data = data2D.mask[np.isfinite(data2D.data)]
 
         dq_data = None
@@ -448,18 +456,19 @@
             dq_overlap_y *= dq_overlap_y
 
-            dq_overlap = numpy.sqrt((dq_overlap_x + dq_overlap_y) / 2.0)
+            dq_overlap = np.sqrt((dq_overlap_x + dq_overlap_y) / 2.0)
             # Final protection of dq
             if dq_overlap < 0:
                 dq_overlap = y_min
-            dqx_data = data2D.dqx_data[numpy.isfinite(data2D.data)]
-            dqy_data = data2D.dqy_data[numpy.isfinite(data2D.data)] - dq_overlap
+            dqx_data = data2D.dqx_data[np.isfinite(data2D.data)]
+            dqy_data = data2D.dqy_data[np.isfinite(
+                data2D.data)] - dq_overlap
             # def; dqx_data = dq_r dqy_data = dq_phi
             # Convert dq 2D to 1D here
             dqx = dqx_data * dqx_data
             dqy = dqy_data * dqy_data
-            dq_data = numpy.add(dqx, dqy)
-            dq_data = numpy.sqrt(dq_data)
-
-        #q_data_max = numpy.max(q_data)
+            dq_data = np.add(dqx, dqy)
+            dq_data = np.sqrt(dq_data)
+
+        #q_data_max = np.max(q_data)
         if len(data2D.q_data) == None:
             msg = "Circular averaging: invalid q_data: %g" % data2D.q_data
@@ -469,9 +478,9 @@
         nbins = int(math.ceil((self.r_max - self.r_min) / self.bin_width))
 
-        x = numpy.zeros(nbins)
-        y = numpy.zeros(nbins)
-        err_y = numpy.zeros(nbins)
-        err_x = numpy.zeros(nbins)
-        y_counts = numpy.zeros(nbins)
+        x = np.zeros(nbins)
+        y = np.zeros(nbins)
+        err_y = np.zeros(nbins)
+        err_x = np.zeros(nbins)
+        y_counts = np.zeros(nbins)
 
         for npt in range(len(data)):
@@ -486,5 +495,5 @@
             data_n = data[npt]
 
-            ## No need to calculate the frac when all data are within range
+            # No need to calculate the frac when all data are within range
             if self.r_min >= self.r_max:
                 raise ValueError, "Limit Error: min > max"
@@ -502,5 +511,5 @@
             # Take dqs from data to get the q_average
             x[i_q] += frac * q_value
-            if err_data == None or err_data[npt] == 0.0:
+            if err_data is None or err_data[npt] == 0.0:
                 if data_n < 0:
                     data_n = -data_n
@@ -523,12 +532,12 @@
                 err_y[n] = -err_y[n]
             err_y[n] = math.sqrt(err_y[n])
-            #if err_x != None:
+            # if err_x != None:
             #    err_x[n] = math.sqrt(err_x[n])
 
         err_y = err_y / y_counts
-        err_y[err_y == 0] = numpy.average(err_y)
+        err_y[err_y == 0] = np.average(err_y)
         y = y / y_counts
         x = x / y_counts
-        idx = (numpy.isfinite(y)) & (numpy.isfinite(x))
+        idx = (np.isfinite(y)) & (np.isfinite(x))
 
         if err_x != None:
@@ -556,5 +565,6 @@
     in anti-clockwise starting from the x- axis on the left-hand side
     """
-    #Todo: remove center.
+    # Todo: remove center.
+
     def __init__(self, r_min=0, r_max=0, center_x=0, center_y=0, nbins=36):
         # Minimum radius
@@ -569,5 +579,4 @@
         self.nbins_phi = nbins
 
-
     def __call__(self, data2D):
         """
@@ -585,15 +594,15 @@
 
         # Get data
-        data = data2D.data[numpy.isfinite(data2D.data)]
-        q_data = data2D.q_data[numpy.isfinite(data2D.data)]
-        err_data = data2D.err_data[numpy.isfinite(data2D.data)]
-        qx_data = data2D.qx_data[numpy.isfinite(data2D.data)]
-        qy_data = data2D.qy_data[numpy.isfinite(data2D.data)]
+        data = data2D.data[np.isfinite(data2D.data)]
+        q_data = data2D.q_data[np.isfinite(data2D.data)]
+        err_data = data2D.err_data[np.isfinite(data2D.data)]
+        qx_data = data2D.qx_data[np.isfinite(data2D.data)]
+        qy_data = data2D.qy_data[np.isfinite(data2D.data)]
 
         # Set space for 1d outputs
-        phi_bins = numpy.zeros(self.nbins_phi)
-        phi_counts = numpy.zeros(self.nbins_phi)
-        phi_values = numpy.zeros(self.nbins_phi)
-        phi_err = numpy.zeros(self.nbins_phi)
+        phi_bins = np.zeros(self.nbins_phi)
+        phi_counts = np.zeros(self.nbins_phi)
+        phi_values = np.zeros(self.nbins_phi)
+        phi_err = np.zeros(self.nbins_phi)
 
         # Shift to apply to calculated phi values in order
@@ -615,5 +624,5 @@
                 continue
             # binning
-            i_phi = int(math.floor((self.nbins_phi) * \
+            i_phi = int(math.floor((self.nbins_phi) *
                                    (phi_value + phi_shift) / (2 * Pi)))
 
@@ -623,5 +632,5 @@
             phi_bins[i_phi] += frac * data[npt]
 
-            if err_data == None or err_data[npt] == 0.0:
+            if err_data is None or err_data[npt] == 0.0:
                 if data_n < 0:
                     data_n = -data_n
@@ -636,10 +645,10 @@
             phi_values[i] = 2.0 * math.pi / self.nbins_phi * (1.0 * i)
 
-        idx = (numpy.isfinite(phi_bins))
+        idx = (np.isfinite(phi_bins))
 
         if not idx.any():
             msg = "Average Error: No points inside ROI to average..."
             raise ValueError, msg
-        #elif len(phi_bins[idx])!= self.nbins_phi:
+        # elif len(phi_bins[idx])!= self.nbins_phi:
         #    print "resulted",self.nbins_phi- len(phi_bins[idx])
         #,"empty bin(s) due to tight binning..."
@@ -748,4 +757,5 @@
     starting from the x- axis on the left-hand side
     """
+
     def __init__(self, r_min, r_max, phi_min=0, phi_max=2 * math.pi, nbins=20):
         self.r_min = r_min
@@ -769,9 +779,9 @@
 
         # Get the all data & info
-        data = data2D.data[numpy.isfinite(data2D.data)]
-        q_data = data2D.q_data[numpy.isfinite(data2D.data)]
-        err_data = data2D.err_data[numpy.isfinite(data2D.data)]
-        qx_data = data2D.qx_data[numpy.isfinite(data2D.data)]
-        qy_data = data2D.qy_data[numpy.isfinite(data2D.data)]
+        data = data2D.data[np.isfinite(data2D.data)]
+        q_data = data2D.q_data[np.isfinite(data2D.data)]
+        err_data = data2D.err_data[np.isfinite(data2D.data)]
+        qx_data = data2D.qx_data[np.isfinite(data2D.data)]
+        qy_data = data2D.qy_data[np.isfinite(data2D.data)]
         dq_data = None
 
@@ -803,22 +813,23 @@
             dq_overlap_y *= dq_overlap_y
 
-            dq_overlap = numpy.sqrt((dq_overlap_x + dq_overlap_y) / 2.0)
+            dq_overlap = np.sqrt((dq_overlap_x + dq_overlap_y) / 2.0)
             if dq_overlap < 0:
                 dq_overlap = y_min
-            dqx_data = data2D.dqx_data[numpy.isfinite(data2D.data)]
-            dqy_data = data2D.dqy_data[numpy.isfinite(data2D.data)] - dq_overlap
+            dqx_data = data2D.dqx_data[np.isfinite(data2D.data)]
+            dqy_data = data2D.dqy_data[np.isfinite(
+                data2D.data)] - dq_overlap
             # def; dqx_data = dq_r dqy_data = dq_phi
             # Convert dq 2D to 1D here
             dqx = dqx_data * dqx_data
             dqy = dqy_data * dqy_data
-            dq_data = numpy.add(dqx, dqy)
-            dq_data = numpy.sqrt(dq_data)
-
-        #set space for 1d outputs
-        x = numpy.zeros(self.nbins)
-        y = numpy.zeros(self.nbins)
-        y_err = numpy.zeros(self.nbins)
-        x_err = numpy.zeros(self.nbins)
-        y_counts = numpy.zeros(self.nbins)
+            dq_data = np.add(dqx, dqy)
+            dq_data = np.sqrt(dq_data)
+
+        # set space for 1d outputs
+        x = np.zeros(self.nbins)
+        y = np.zeros(self.nbins)
+        y_err = np.zeros(self.nbins)
+        x_err = np.zeros(self.nbins)
+        y_counts = np.zeros(self.nbins)
 
         # Get the min and max into the region: 0 <= phi < 2Pi
@@ -839,12 +850,12 @@
             phi_value = math.atan2(qy_data[n], qx_data[n]) + Pi
 
-            ## No need to calculate the frac when all data are within range
+            # No need to calculate the frac when all data are within range
             if self.r_min <= q_value and q_value <= self.r_max:
                 frac = 1
             if frac == 0:
                 continue
-            #In case of two ROIs (symmetric major and minor regions)(for 'q2')
+            # In case of two ROIs (symmetric major and minor regions)(for 'q2')
             if run.lower() == 'q2':
-                ## For minor sector wing
+                # For minor sector wing
                 # Calculate the minor wing phis
                 phi_min_minor = flip_phi(phi_min - Pi)
@@ -852,18 +863,18 @@
                 # Check if phis of the minor ring is within 0 to 2pi
                 if phi_min_minor > phi_max_minor:
-                    is_in = (phi_value > phi_min_minor or \
-                              phi_value < phi_max_minor)
+                    is_in = (phi_value > phi_min_minor or
+                             phi_value < phi_max_minor)
                 else:
-                    is_in = (phi_value > phi_min_minor and \
-                              phi_value < phi_max_minor)
-
-            #For all cases(i.e.,for 'q', 'q2', and 'phi')
-            #Find pixels within ROI
+                    is_in = (phi_value > phi_min_minor and
+                             phi_value < phi_max_minor)
+
+            # For all cases(i.e.,for 'q', 'q2', and 'phi')
+            # Find pixels within ROI
             if phi_min > phi_max:
-                is_in = is_in or (phi_value > phi_min or \
-                                   phi_value < phi_max)
+                is_in = is_in or (phi_value > phi_min or
+                                  phi_value < phi_max)
             else:
-                is_in = is_in or (phi_value >= phi_min  and \
-                                    phi_value < phi_max)
+                is_in = is_in or (phi_value >= phi_min and
+                                  phi_value < phi_max)
 
             if not is_in:
@@ -885,5 +896,5 @@
                 i_bin = self.nbins - 1
 
-            ## Get the total y
+            # Get the total y
             y[i_bin] += frac * data_n
             x[i_bin] += frac * q_value
@@ -923,6 +934,6 @@
                 #x[i] = math.sqrt((r_inner * r_inner + r_outer * r_outer) / 2)
                 x[i] = x[i] / y_counts[i]
-        y_err[y_err == 0] = numpy.average(y_err)
-        idx = (numpy.isfinite(y) & numpy.isfinite(y_err))
+        y_err[y_err == 0] = np.average(y_err)
+        idx = (np.isfinite(y) & np.isfinite(y_err))
         if x_err != None:
             d_x = x_err[idx] / y_counts[idx]
@@ -932,5 +943,5 @@
             msg = "Average Error: No points inside sector of ROI to average..."
             raise ValueError, msg
-        #elif len(y[idx])!= self.nbins:
+        # elif len(y[idx])!= self.nbins:
         #    print "resulted",self.nbins- len(y[idx]),
         #"empty bin(s) due to tight binning..."
@@ -946,4 +957,5 @@
     The number of bin in phi also has to be defined.
     """
+
     def __call__(self, data2D):
         """
@@ -965,4 +977,5 @@
     The number of bin in Q also has to be defined.
     """
+
     def __call__(self, data2D):
         """
@@ -987,4 +1000,5 @@
     in anti-clockwise starting from the x- axis on the left-hand side
     """
+
     def __init__(self, r_min=0, r_max=0, center_x=0, center_y=0):
         # Minimum radius
@@ -1012,5 +1026,5 @@
         qx_data = data2D.qx_data
         qy_data = data2D.qy_data
-        q_data = numpy.sqrt(qx_data * qx_data + qy_data * qy_data)
+        q_data = np.sqrt(qx_data * qx_data + qy_data * qy_data)
 
         # check whether or not the data point is inside ROI
@@ -1023,4 +1037,5 @@
     Find a rectangular 2D region of interest.
     """
+
     def __init__(self, x_min=0.0, x_max=0.0, y_min=0.0, y_max=0.0):
         # Minimum Qx value [A-1]
@@ -1077,4 +1092,5 @@
     and (phi_max-phi_min) should not be larger than pi
     """
+
     def __init__(self, phi_min=0, phi_max=math.pi):
         self.phi_min = phi_min
@@ -1113,5 +1129,5 @@
 
         # get phi from data
-        phi_data = numpy.arctan2(qy_data, qx_data)
+        phi_data = np.arctan2(qy_data, qx_data)
 
         # Get the min and max into the region: -pi <= phi < Pi
@@ -1120,7 +1136,9 @@
         # check for major sector
         if phi_min_major > phi_max_major:
-            out_major = (phi_min_major <= phi_data) + (phi_max_major > phi_data)
+            out_major = (phi_min_major <= phi_data) + \
+                (phi_max_major > phi_data)
         else:
-            out_major = (phi_min_major <= phi_data) & (phi_max_major > phi_data)
+            out_major = (phi_min_major <= phi_data) & (
+                phi_max_major > phi_data)
 
         # minor sector
@@ -1132,8 +1150,8 @@
         if phi_min_minor > phi_max_minor:
             out_minor = (phi_min_minor <= phi_data) + \
-                            (phi_max_minor >= phi_data)
+                (phi_max_minor >= phi_data)
         else:
             out_minor = (phi_min_minor <= phi_data) & \
-                            (phi_max_minor >= phi_data)
+                (phi_max_minor >= phi_data)
         out = out_major + out_minor
 
Index: test/sasguiframe/test/utest_manipulations.py
===================================================================
--- test/sasguiframe/test/utest_manipulations.py	(revision 9a5097cd1c76689d1f997b85ba43d12a95d8f243)
+++ test/sasguiframe/test/utest_manipulations.py	(revision fd5d6eac046494e899ed8c6951bb2e8900b24d0f)
@@ -2,21 +2,23 @@
     Unit tests for data manipulations
 """
-#TODO: what happens if you add a Data1D to a Data2D?
-
+# TODO: what happens if you add a Data1D to a Data2D?
+
+import math
+import os.path
 import unittest
-import math
+
 import numpy as np
-from sas.sascalc.dataloader.loader import  Loader
-from sas.sasgui.guiframe.dataFitting import Data1D, Data2D
+
+from sas.sascalc.dataloader.loader import Loader
 from sas.sasgui.guiframe.dataFitting import Data1D as Theory1D
- 
-import os.path
+from sas.sasgui.guiframe.dataFitting import Data2D
+
 
 class data_info_tests(unittest.TestCase):
-    
+
     def setUp(self):
         data = Loader().load("cansas1d.xml")
         self.data = data[0]
-        
+
     def test_clone1D(self):
         """
@@ -24,14 +26,16 @@
         """
         clone = self.data.clone_without_data()
-        
+
         for i in range(len(self.data.detector)):
-            self.assertEqual(self.data.detector[i].distance, clone.detector[i].distance)
-            
+            self.assertEqual(
+                self.data.detector[i].distance, clone.detector[i].distance)
+
+
 class theory1d_tests(unittest.TestCase):
-    
+
     def setUp(self):
         data = Loader().load("cansas1d.xml")
         self.data = data[0]
-        
+
     def test_clone_theory1D(self):
         """
@@ -42,6 +46,7 @@
         theory.copy_from_datainfo(data1d=self.data)
         for i in range(len(self.data.detector)):
-            self.assertEqual(self.data.detector[i].distance, theory.detector[i].distance)
-            
+            self.assertEqual(
+                self.data.detector[i].distance, theory.detector[i].distance)
+
         for i in range(len(self.data.x)):
             self.assertEqual(self.data.x[i], theory.x[i])
@@ -49,22 +54,22 @@
             self.assertEqual(self.data.dy[i], theory.dy[i])
 
+
 class manip_tests(unittest.TestCase):
-    
+
     def setUp(self):
         # Create two data sets to play with
         x_0 = np.ones(5)
         for i in range(5):
-            x_0[i] = x_0[i]*(i+1.0)
-            
-        y_0 = 2.0*np.ones(5)
-        dy_0 = 0.5*np.ones(5)
+            x_0[i] = x_0[i] * (i + 1.0)
+
+        y_0 = 2.0 * np.ones(5)
+        dy_0 = 0.5 * np.ones(5)
         self.data = Data1D(x_0, y_0, dy=dy_0)
-        
+
         x = self.data.x
         y = np.ones(5)
         dy = np.ones(5)
         self.data2 = Data1D(x, y, dy=dy)
-        
-        
+
     def test_load(self):
         """
@@ -73,99 +78,102 @@
         # There should be 5 entries in the file
         self.assertEqual(len(self.data.x), 5)
-        
+
         for i in range(5):
             # The x values should be from 1 to 5
-            self.assertEqual(self.data.x[i], float(i+1))
-        
+            self.assertEqual(self.data.x[i], float(i + 1))
+
             # All y-error values should be 0.5
-            self.assertEqual(self.data.dy[i], 0.5)    
-            
+            self.assertEqual(self.data.dy[i], 0.5)
+
             # All y values should be 2.0
-            self.assertEqual(self.data.y[i], 2.0)    
-        
+            self.assertEqual(self.data.y[i], 2.0)
+
     def test_add(self):
-        result = self.data2+self.data
+        result = self.data2 + self.data
         for i in range(5):
             self.assertEqual(result.y[i], 3.0)
-            self.assertEqual(result.dy[i], math.sqrt(0.5**2+1.0))
-        
+            self.assertEqual(result.dy[i], math.sqrt(0.5**2 + 1.0))
+
     def test_sub(self):
-        result = self.data2-self.data
+        result = self.data2 - self.data
         for i in range(5):
             self.assertEqual(result.y[i], -1.0)
-            self.assertEqual(result.dy[i], math.sqrt(0.5**2+1.0))
-        
+            self.assertEqual(result.dy[i], math.sqrt(0.5**2 + 1.0))
+
     def test_mul(self):
-        result = self.data2*self.data
+        result = self.data2 * self.data
         for i in range(5):
             self.assertEqual(result.y[i], 2.0)
-            self.assertEqual(result.dy[i], math.sqrt((0.5*1.0)**2+(1.0*2.0)**2))
-        
+            self.assertEqual(result.dy[i], math.sqrt(
+                (0.5 * 1.0)**2 + (1.0 * 2.0)**2))
+
     def test_div(self):
-        result = self.data2/self.data
+        result = self.data2 / self.data
         for i in range(5):
             self.assertEqual(result.y[i], 0.5)
-            self.assertEqual(result.dy[i], math.sqrt((1.0/2.0)**2+(0.5*1.0/4.0)**2))
-        
+            self.assertEqual(result.dy[i], math.sqrt(
+                (1.0 / 2.0)**2 + (0.5 * 1.0 / 4.0)**2))
+
     def test_radd(self):
-        result = self.data+3.0
+        result = self.data + 3.0
         for i in range(5):
             self.assertEqual(result.y[i], 5.0)
             self.assertEqual(result.dy[i], 0.5)
-            
-        result = 3.0+self.data
+
+        result = 3.0 + self.data
         for i in range(5):
             self.assertEqual(result.y[i], 5.0)
             self.assertEqual(result.dy[i], 0.5)
-            
+
     def test_rsub(self):
-        result = self.data-3.0
+        result = self.data - 3.0
         for i in range(5):
             self.assertEqual(result.y[i], -1.0)
             self.assertEqual(result.dy[i], 0.5)
-            
-        result = 3.0-self.data
+
+        result = 3.0 - self.data
         for i in range(5):
             self.assertEqual(result.y[i], 1.0)
             self.assertEqual(result.dy[i], 0.5)
-            
+
     def test_rmul(self):
-        result = self.data*3.0
+        result = self.data * 3.0
         for i in range(5):
             self.assertEqual(result.y[i], 6.0)
             self.assertEqual(result.dy[i], 1.5)
-            
-        result = 3.0*self.data
+
+        result = 3.0 * self.data
         for i in range(5):
             self.assertEqual(result.y[i], 6.0)
             self.assertEqual(result.dy[i], 1.5)
-            
+
     def test_rdiv(self):
-        result = self.data/4.0
+        result = self.data / 4.0
         for i in range(5):
             self.assertEqual(result.y[i], 0.5)
             self.assertEqual(result.dy[i], 0.125)
-            
-        result = 6.0/self.data
+
+        result = 6.0 / self.data
         for i in range(5):
             self.assertEqual(result.y[i], 3.0)
-            self.assertEqual(result.dy[i], 6.0*0.5/4.0)
-            
+            self.assertEqual(result.dy[i], 6.0 * 0.5 / 4.0)
+
+
 class manip_2D(unittest.TestCase):
-    
+
     def setUp(self):
         # Create two data sets to play with
-        x_0 = 2.0*np.ones(25)
-        dx_0 = 0.5*np.ones(25)
+        x_0 = 2.0 * np.ones(25)
+        dx_0 = 0.5 * np.ones(25)
         qx_0 = np.arange(25)
         qy_0 = np.arange(25)
         mask_0 = np.zeros(25)
-        dqx_0 = np.arange(25)/100
-        dqy_0 = np.arange(25)/100
+        dqx_0 = np.arange(25) / 100
+        dqy_0 = np.arange(25) / 100
         q_0 = np.sqrt(qx_0 * qx_0 + qy_0 * qy_0)
-        self.data = Data2D(image=x_0, err_image=dx_0, qx_data=qx_0, 
-                           qy_data=qy_0, q_data=q_0, mask=mask_0, 
+        self.data = Data2D(image=x_0, err_image=dx_0, qx_data=qx_0,
+                           qy_data=qy_0, q_data=q_0, mask=mask_0,
                            dqx_data=dqx_0, dqy_data=dqy_0)
-        
+
         y = np.ones(25)
         dy = np.ones(25)
@@ -174,8 +182,7 @@
         mask = np.zeros(25)
         q = np.sqrt(qx * qx + qy * qy)
-        self.data2 = Data2D(image=y, err_image=dy, qx_data=qx, qy_data=qy, 
+        self.data2 = Data2D(image=y, err_image=dy, qx_data=qx, qy_data=qy,
                             q_data=q, mask=mask)
-        
-        
+
     def test_load(self):
         """
@@ -184,96 +191,99 @@
         # There should be 5 entries in the file
         self.assertEqual(np.size(self.data.data), 25)
-        
+
         for i in range(25):
             # All y-error values should be 0.5
-            self.assertEqual(self.data.err_data[i], 0.5)    
-            
+            self.assertEqual(self.data.err_data[i], 0.5)
+
             # All y values should be 2.0
-            self.assertEqual(self.data.data[i], 2.0)    
-        
+            self.assertEqual(self.data.data[i], 2.0)
+
     def test_add(self):
-        result = self.data2+self.data
+        result = self.data2 + self.data
         for i in range(25):
             self.assertEqual(result.data[i], 3.0)
-            self.assertEqual(result.err_data[i], math.sqrt(0.5**2+1.0))
-        
+            self.assertEqual(result.err_data[i], math.sqrt(0.5**2 + 1.0))
+
     def test_sub(self):
-        result = self.data2-self.data
-        for i in range(25):
-                self.assertEqual(result.data[i], -1.0)
-                self.assertEqual(result.err_data[i], math.sqrt(0.5**2+1.0))
-        
+        result = self.data2 - self.data
+        for i in range(25):
+            self.assertEqual(result.data[i], -1.0)
+            self.assertEqual(result.err_data[i], math.sqrt(0.5**2 + 1.0))
+
     def test_mul(self):
-        result = self.data2*self.data
+        result = self.data2 * self.data
         for i in range(25):
             self.assertEqual(result.data[i], 2.0)
-            self.assertEqual(result.err_data[i], math.sqrt((0.5*1.0)**2+(1.0*2.0)**2))
-        
+            self.assertEqual(result.err_data[i], math.sqrt(
+                (0.5 * 1.0)**2 + (1.0 * 2.0)**2))
+
     def test_div(self):
-        result = self.data2/self.data
+        result = self.data2 / self.data
         for i in range(25):
             self.assertEqual(result.data[i], 0.5)
-            self.assertEqual(result.err_data[i], math.sqrt((1.0/2.0)**2+(0.5*1.0/4.0)**2))
-        
+            self.assertEqual(result.err_data[i], math.sqrt(
+                (1.0 / 2.0)**2 + (0.5 * 1.0 / 4.0)**2))
+
     def test_radd(self):
-        result = self.data+3.0
+        result = self.data + 3.0
         for i in range(25):
             self.assertEqual(result.data[i], 5.0)
             self.assertEqual(result.err_data[i], 0.5)
-   
-        result = 3.0+self.data
+
+        result = 3.0 + self.data
         for i in range(25):
             self.assertEqual(result.data[i], 5.0)
             self.assertEqual(result.err_data[i], 0.5)
-            
+
     def test_rsub(self):
-        result = self.data-3.0
+        result = self.data - 3.0
         for i in range(25):
             self.assertEqual(result.data[i], -1.0)
             self.assertEqual(result.err_data[i], 0.5)
-    
-        result = 3.0-self.data
+
+        result = 3.0 - self.data
         for i in range(25):
             self.assertEqual(result.data[i], 1.0)
             self.assertEqual(result.err_data[i], 0.5)
-            
+
     def test_rmul(self):
-        result = self.data*3.0
+        result = self.data * 3.0
         for i in range(25):
             self.assertEqual(result.data[i], 6.0)
             self.assertEqual(result.err_data[i], 1.5)
- 
-        result = 3.0*self.data
+
+        result = 3.0 * self.data
         for i in range(25):
             self.assertEqual(result.data[i], 6.0)
             self.assertEqual(result.err_data[i], 1.5)
-            
+
     def test_rdiv(self):
-        result = self.data/4.0
+        result = self.data / 4.0
         for i in range(25):
             self.assertEqual(result.data[i], 0.5)
             self.assertEqual(result.err_data[i], 0.125)
 
-        result = 6.0/self.data
+        result = 6.0 / self.data
         for i in range(25):
             self.assertEqual(result.data[i], 3.0)
-            self.assertEqual(result.err_data[i], 6.0*0.5/4.0)
-    
+            self.assertEqual(result.err_data[i], 6.0 * 0.5 / 4.0)
+
+
 class extra_manip_2D(unittest.TestCase):
-    
+
     def setUp(self):
         # Create two data sets to play with
-        x_0 = 2.0*np.ones(25)
-        dx_0 = 0.5*np.ones(25)
+        x_0 = 2.0 * np.ones(25)
+        dx_0 = 0.5 * np.ones(25)
         qx_0 = np.arange(25)
         qy_0 = np.arange(25)
         mask_0 = np.zeros(25)
-        dqx_0 = np.arange(25)/100
-        dqy_0 = np.arange(25)/100
+        dqx_0 = np.arange(25) / 100
+        dqy_0 = np.arange(25) / 100
         q_0 = np.sqrt(qx_0 * qx_0 + qy_0 * qy_0)
-        self.data = Data2D(image=x_0, err_image=dx_0, qx_data=qx_0, 
-                           qy_data=qy_0, q_data=q_0, mask=mask_0, 
+        self.data = Data2D(image=x_0, err_image=dx_0, qx_data=qx_0,
+                           qy_data=qy_0, q_data=q_0, mask=mask_0,
                            dqx_data=dqx_0, dqy_data=dqy_0)
-        
+
         y = np.ones(25)
         dy = np.ones(25)
@@ -282,8 +292,7 @@
         mask = np.zeros(25)
         q = np.sqrt(qx * qx + qy * qy)
-        self.data2 = Data2D(image=y, err_image=dy, qx_data=qx, qy_data=qy, 
+        self.data2 = Data2D(image=y, err_image=dy, qx_data=qx, qy_data=qy,
                             q_data=q, mask=mask)
-        
-        
+
     def test_load(self):
         """
@@ -292,81 +301,83 @@
         # There should be 5 entries in the file
         self.assertEqual(np.size(self.data.data), 25)
-        
+
         for i in range(25):
             # All y-error values should be 0.5
-            self.assertEqual(self.data.err_data[i], 0.5)    
-            
+            self.assertEqual(self.data.err_data[i], 0.5)
+
             # All y values should be 2.0
-            self.assertEqual(self.data.data[i], 2.0)    
-        
+            self.assertEqual(self.data.data[i], 2.0)
+
     def test_add(self):
-        result = self.data2+self.data
+        result = self.data2 + self.data
         for i in range(25):
             self.assertEqual(result.data[i], 3.0)
-            self.assertEqual(result.err_data[i], math.sqrt(0.5**2+1.0))
-        
+            self.assertEqual(result.err_data[i], math.sqrt(0.5**2 + 1.0))
+
     def test_sub(self):
-        result = self.data2-self.data
-        for i in range(25):
-                self.assertEqual(result.data[i], -1.0)
-                self.assertEqual(result.err_data[i], math.sqrt(0.5**2+1.0))
-        
+        result = self.data2 - self.data
+        for i in range(25):
+            self.assertEqual(result.data[i], -1.0)
+            self.assertEqual(result.err_data[i], math.sqrt(0.5**2 + 1.0))
+
     def test_mul(self):
-        result = self.data2*self.data
+        result = self.data2 * self.data
         for i in range(25):
             self.assertEqual(result.data[i], 2.0)
-            self.assertEqual(result.err_data[i], math.sqrt((0.5*1.0)**2+(1.0*2.0)**2))
-        
+            self.assertEqual(result.err_data[i], math.sqrt(
+                (0.5 * 1.0)**2 + (1.0 * 2.0)**2))
+
     def test_div(self):
-        result = self.data2/self.data
+        result = self.data2 / self.data
         for i in range(25):
             self.assertEqual(result.data[i], 0.5)
-            self.assertEqual(result.err_data[i], math.sqrt((1.0/2.0)**2+(0.5*1.0/4.0)**2))
-        
+            self.assertEqual(result.err_data[i], math.sqrt(
+                (1.0 / 2.0)**2 + (0.5 * 1.0 / 4.0)**2))
+
     def test_radd(self):
-        result = self.data+3.0
+        result = self.data + 3.0
         for i in range(25):
             self.assertEqual(result.data[i], 5.0)
             self.assertEqual(result.err_data[i], 0.5)
-   
-        result = 3.0+self.data
+
+        result = 3.0 + self.data
         for i in range(25):
             self.assertEqual(result.data[i], 5.0)
             self.assertEqual(result.err_data[i], 0.5)
-            
+
     def test_rsub(self):
-        result = self.data-3.0
+        result = self.data - 3.0
         for i in range(25):
             self.assertEqual(result.data[i], -1.0)
             self.assertEqual(result.err_data[i], 0.5)
-    
-        result = 3.0-self.data
+
+        result = 3.0 - self.data
         for i in range(25):
             self.assertEqual(result.data[i], 1.0)
             self.assertEqual(result.err_data[i], 0.5)
-            
+
     def test_rmul(self):
-        result = self.data*3.0
+        result = self.data * 3.0
         for i in range(25):
             self.assertEqual(result.data[i], 6.0)
             self.assertEqual(result.err_data[i], 1.5)
- 
-        result = 3.0*self.data
+
+        result = 3.0 * self.data
         for i in range(25):
             self.assertEqual(result.data[i], 6.0)
             self.assertEqual(result.err_data[i], 1.5)
-            
+
     def test_rdiv(self):
-        result = self.data/4.0
+        result = self.data / 4.0
         for i in range(25):
             self.assertEqual(result.data[i], 0.5)
             self.assertEqual(result.err_data[i], 0.125)
 
-        result = 6.0/self.data
+        result = 6.0 / self.data
         for i in range(25):
             self.assertEqual(result.data[i], 3.0)
-            self.assertEqual(result.err_data[i], 6.0*0.5/4.0)
+            self.assertEqual(result.err_data[i], 6.0 * 0.5 / 4.0)
+
 
 if __name__ == '__main__':
     unittest.main()
-   
