Index: Invariant/invariant.py
===================================================================
--- Invariant/invariant.py	(revision aafa962bf871a37b5ba098610635d93c7a8f200f)
+++ Invariant/invariant.py	(revision 76c17272262699f8d86f9ceaf30f7f02c1521f0a)
@@ -24,14 +24,57 @@
         function given some x, y 
     """
-    def linearize_data(self, x, y, dy=None):
+    
+    def linearize_data(self, data):
         """
             Linearize data so that a linear fit can be performed. 
             Filter out the data that can't be transformed.
-            @param x: array of q values
-            @param y: array of I(q) values
-            @param dy: array of dI(q) values
+            @param data : LoadData1D instance
+        """
+        # Check that the vector lengths are equal
+        assert(len(data.x)==len(data.y))
+        if data.dy is not None:
+            assert(len(data.x)==len(data.dy))
+            dy = data.dy
+        else:
+            dy = numpy.array([math.sqrt(math.fabs(j)) for j in data.y])
+        # Transform smear info 
+        dxl_out = None
+        dxw_out = None
+        dx_out = None
+        first_x = data.x#[0] 
+        #if first_x == 0:
+        #    first_x = data.x[1]
+            
+           
+        data_points = zip(data.x, data.y, dy)
+        
+        # Transform the data
+        output_points = [(self.linearize_q_value(p[0]),
+                          math.log(p[1]),
+                          p[2]/p[1]) for p in data_points if p[0]>0 and p[1]>0]
+        
+        x_out, y_out, dy_out = zip(*output_points)
+       
+        #Transform smear info    
+        if data.dxl is not None  and len(data.dxl)>0:
+            dxl_out = self.linearize_dq_value(x=x_out, dx=data.dxl[:len(x_out)])
+        if data.dxw is not None and len(data.dxw)>0:
+            dxw_out = self.linearize_dq_value(x=x_out, dx=data.dxw[:len(x_out)])
+        if data.dx is not None  and len(data.dx)>0:
+            dx_out = self.linearize_dq_value(x=x_out, dx=data.dx[:len(x_out)])
+        x_out = numpy.asarray(x_out)
+        y_out = numpy.asarray(y_out)
+        dy_out = numpy.asarray(dy_out)
+        linear_data = LoaderData1D(x=x_out, y=y_out, dx=dx_out, dy=dy_out)
+        linear_data.dxl = dxl_out
+        linear_data.dxw = dxw_out
+        
+        return linear_data
+    def linearize_dq_value(self, x, dx):
+        """
+            Transform the input dq-value for linearization
         """
         return NotImplemented
-    
+
     def linearize_q_value(self, value):
         """
@@ -61,30 +104,10 @@
         self.scale = scale
         self.radius = radius
-    
-    def linearize_data(self, x, y, dy=None):
-        """
-            Linearize data so that a linear fit can be performed. 
-            Filter out the data that can't be transformed.
-            @param x: array of q values
-            @param y: array of I(q) values
-            @param dy: array of dI(q) values
-        """
-        # Check that the vector lengths are equal
-        assert(len(x)==len(y))
-        if dy is not None:
-            assert(len(x)==len(dy))
-        else:
-            dy = numpy.array([math.sqrt(math.fabs(j)) for j in y])
-        
-        data_points = zip(x,y,dy)
-        
-        # Transform the data
-        output_points = [(self.linearize_q_value(p[0]),
-                          math.log(p[1]),
-                          p[2]/p[1]) for p in data_points if p[0]>0 and p[1]>0]
-        
-        x_out, y_out, dy_out = zip(*output_points)
-
-        return numpy.asarray(x_out), numpy.asarray(y_out), numpy.asarray(dy_out)
+        
+    def linearize_dq_value(self, x, dx):
+        """
+            Transform the input dq-value for linearization
+        """
+        return numpy.array([2*x[0]*dx[0] for i in xrange(len(x))]) 
     
     def linearize_q_value(self, value):
@@ -138,31 +161,11 @@
         self.scale = scale
         self.power = power
-        
-    def linearize_data(self, x, y, dy=None):
-        """
-            Linearize data so that a linear fit can be performed. 
-            Filter out the data that can't be transformed.
-            @param x: array of q values
-            @param y: array of I(q) values
-            @param dy: array of dI(q) values
-        """
-        # Check that the vector lengths are equal
-        assert(len(x)==len(y))
-        if dy is not None:
-            assert(len(x)==len(dy))
-        else:
-            dy = numpy.array([math.sqrt(math.fabs(j)) for j in y])
-        
-        data_points = zip(x,y,dy)
-        
-        # Transform the data
-        output_points = [(self.linearize_q_value(p[0]),
-                          math.log(p[1]),
-                          p[2]/p[1]) for p in data_points if p[0]>0 and p[1]>0]
-        
-        x_out, y_out, dy_out = zip(*output_points)
-
-        return numpy.asarray(x_out), numpy.asarray(y_out), numpy.asarray(dy_out)
-        
+   
+    def linearize_dq_value(self, x, dx):
+        """
+            Transform the input dq-value for linearization
+        """
+        return  numpy.array([dx[0]/x[0] for i in xrange(len(x))]) 
+    
     def linearize_q_value(self, value):
         """
@@ -301,6 +304,4 @@
         @note: Some computations depends on each others. 
     """
-    
-    
     def __init__(self, data, background=0, scale=1 ):
         """
@@ -365,13 +366,8 @@
         """
         # Linearize the data in preparation for fitting
-        fit_x, fit_y, fit_dy = model.linearize_data(self._data.x, self._data.y, self._data.dy)
-      
+        fit_data = model.linearize_data(self._data)
         qmin = model.linearize_q_value(qmin)
         qmax = model.linearize_q_value(qmax)
-        
-        # Create a new Data1D object for processing
-        fit_data = LoaderData1D(x=fit_x, y=fit_y, dy=fit_dy)
-        fit_data.dxl = self._data.dxl
-        fit_data.dxw = self._data.dxw   
+        # Get coefficient cmoning out of the  fit
         extrapolator = Extrapolator(data=fit_data)
         extrapolator.set_fit_range(qmin=qmin, qmax=qmax)
@@ -592,30 +588,4 @@
                     sum += (data.x[i] * data.dxl[i] * dy[i] * dxi)**2
                 return math.sqrt(sum)
-   
-    def get_qstar_low(self):
-        """
-            Compute the invariant for extrapolated data at low q range.
-            
-            Implementation:
-                data = self.get_extra_data_low()
-                return self._get_qstar()
-                
-            @return q_star: the invariant for data extrapolated at low q.
-        """
-        data = self.get_extra_data_low()
-        return self._get_qstar(data=data)
-        
-    def get_qstar_high(self):
-        """
-            Compute the invariant for extrapolated data at high q range.
-            
-            Implementation:
-                data = self.get_extra_data_high()
-                return self._get_qstar()
-                
-            @return q_star: the invariant for data extrapolated at high q.
-        """
-        data = self.get_extra_data_high()
-        return self._get_qstar(data=data)
         
     def _get_extrapolated_data(self, model, npts=INTEGRATION_NSTEPS,
@@ -657,6 +627,6 @@
         result_data.dxw = dxw
         return result_data
-        
-    def get_extra_data_low(self):
+    
+    def _get_extra_data_low(self):
         """
             This method creates a new data set from the invariant calculator.
@@ -689,6 +659,6 @@
                          qmax=qmax,
                          power=self._low_extrapolation_power)
+        q_start = Q_MINIMUM
         #q_start point
-        q_start = Q_MINIMUM
         if Q_MINIMUM >= qmin:
             q_start = qmin/10
@@ -699,5 +669,5 @@
         return data_min
           
-    def get_extra_data_high(self):
+    def _get_extra_data_high(self):
         """
             This method creates a new data from the invariant calculator.
@@ -730,4 +700,154 @@
                                                q_start=qmax, q_end=q_end)
         return data_max
+         
+    def get_qstar_low(self):
+        """
+            Compute the invariant for extrapolated data at low q range.
+            
+            Implementation:
+                data = self._get_extra_data_low()
+                return self._get_qstar()
+                
+            @return q_star: the invariant for data extrapolated at low q.
+        """
+        data = self._get_extra_data_low()
+        
+        return self._get_qstar(data=data)
+        
+    def get_qstar_high(self):
+        """
+            Compute the invariant for extrapolated data at high q range.
+            
+            Implementation:
+                data = self._get_extra_data_high()
+                return self._get_qstar()
+                
+            @return q_star: the invariant for data extrapolated at high q.
+        """
+        data = self._get_extra_data_high()
+        return self._get_qstar(data=data)
+    
+    def get_extra_data_low(self, npts_in=None, q_start=Q_MINIMUM, nsteps=INTEGRATION_NSTEPS):
+        """
+            This method creates a new data set from the invariant calculator.
+            
+            It will use the extrapolation parameters kept as private data members.
+            
+            self._low_extrapolation_npts is the number of data points to use in to fit.
+            self._low_extrapolation_function will be used as the fit function.
+            
+            
+            
+            It takes npts first points of data, fits them with a given model
+            then uses the new parameters resulting from the fit to create a new data set.
+            
+            The new data first point is Q_MINIMUM.
+            
+            The last point of the new data is the first point of the original data.
+            the number of q points of this data is INTEGRATION_NSTEPS.
+            
+            @return: a new data of type Data1D
+        """
+        #Create a data from result of the fit for a range outside of the data
+        # at low q range
+        data_out_range = self._get_extra_data_low()
+        
+        if  q_start != Q_MINIMUM or nsteps != INTEGRATION_NSTEPS:
+            qmin = min(self._data.x)
+            if q_start < Q_MINIMUM:
+                q_start = Q_MINIMUM
+            elif q_start >= qmin:
+                q_start = qmin/10
+                
+            #compute the new data with the proper result of the fit for different
+            #boundary and step, outside of data
+            data_out_range = self._get_extrapolated_data(model=self._low_extrapolation_function,
+                                               npts=nsteps,
+                                               q_start=q_start, q_end=qmin)
+        #Create data from the result of the fit for a range inside data q range for
+        #low q
+        if npts_in is None :
+            npts_in = self._low_extrapolation_npts
+
+        x = self._data.x[:npts_in]
+        y = self._low_extrapolation_function.evaluate_model(x=x)
+        dy = None
+        dx = None
+        dxl = None
+        dxw = None
+        if self._data.dx is not None:
+            dx = self._data.dx[:npts_in]
+        if self._data.dy is not None:
+            dy = self._data.dy[:npts_in]
+        if self._data.dxl is not None and len(self._data.dxl)>0:
+            dxl = self._data.dxl[:npts_in]
+        if self._data.dxw is not None and len(self._data.dxw)>0:
+            dxw = self._data.dxw[:npts_in]
+        #Crate new data 
+        data_in_range = LoaderData1D(x=x, y=y, dx=dx, dy=dy)
+        data_in_range.clone_without_data(clone=self._data)
+        data_in_range.dxl = dxl
+        data_in_range.dxw = dxw
+        
+        return data_out_range, data_in_range
+          
+    def get_extra_data_high(self, npts_in=None, q_end=Q_MAXIMUM, nsteps=INTEGRATION_NSTEPS ):
+        """
+            This method creates a new data from the invariant calculator.
+            
+            It takes npts last points of data, fits them with a given model
+            (for this function only power_law will be use), then uses
+            the new parameters resulting from the fit to create a new data set.
+            The first point is the last point of data.
+            The last point of the new data is Q_MAXIMUM.
+            The number of q points of this data is INTEGRATION_NSTEPS.
+
+            
+            @return: a new data of type Data1D
+        """
+        #Create a data from result of the fit for a range outside of the data
+        # at low q range
+        data_out_range = self._get_extra_data_high()
+        qmax = max(self._data.x)
+        if  q_end != Q_MAXIMUM or nsteps != INTEGRATION_NSTEPS:
+            if q_end > Q_MAXIMUM:
+               q_end = Q_MAXIMUM
+            elif q_end <= qmax:
+                q_end = qmax * 10
+                
+            #compute the new data with the proper result of the fit for different
+            #boundary and step, outside of data
+            data_out_range = self._get_extrapolated_data(model=self._high_extrapolation_function,
+                                               npts=nsteps,
+                                               q_start=qmax, q_end=q_end)
+        #Create data from the result of the fit for a range inside data q range for
+        #high q
+        if npts_in is None :
+            npts_in = self._high_extrapolation_npts
+            
+        x_len = len(self._data.x)
+        x = self._data.x[(x_len-npts_in):]
+        y = self._high_extrapolation_function.evaluate_model(x=x)
+        dy = None
+        dx = None
+        dxl = None
+        dxw = None
+        
+        if self._data.dx is not None:
+            dx = self._data.dx[(x_len-npts_in):]
+        if self._data.dy is not None:
+            dy = self._data.dy[(x_len-npts_in):]
+        if self._data.dxl is not None and len(self._data.dxl)>0:
+            dxl = self._data.dxl[(x_len-npts_in):]
+        if self._data.dxw is not None and len(self._data.dxw)>0:
+            dxw = self._data.dxw[(x_len-npts_in):]
+        #Crate new data 
+        data_in_range = LoaderData1D(x=x, y=y, dx=dx, dy=dy)
+        data_in_range.clone_without_data(clone=self._data)
+        data_in_range.dxl = dxl
+        data_in_range.dxw = dxw
+        
+        return data_out_range, data_in_range
+          
      
     def set_extrapolation(self, range, npts=4, function=None, power=None):
Index: Invariant/test/utest_data_handling.py
===================================================================
--- Invariant/test/utest_data_handling.py	(revision 889d5ab4361144b30ea9cc06ed47997c18f7677d)
+++ Invariant/test/utest_data_handling.py	(revision 76c17272262699f8d86f9ceaf30f7f02c1521f0a)
@@ -192,6 +192,8 @@
     def test_guinier_incompatible_length(self):
         g = invariant.Guinier()
-        self.assertRaises(AssertionError, g.linearize_data, [1],[1,2],None)
-        self.assertRaises(AssertionError, g.linearize_data, [1,2],[1,2],[1])
+        data_in = Data1D(x=[1], y=[1,2], dy=None)
+        self.assertRaises(AssertionError, g.linearize_data, data_in)
+        data_in = Data1D(x=[1,1], y=[1,2], dy=[1])
+        self.assertRaises(AssertionError, g.linearize_data, data_in)
     
     def test_linearization(self):
@@ -203,5 +205,7 @@
         y = numpy.asarray(numpy.asarray([1,1,1,1]))
         g = invariant.Guinier()
-        x_out, y_out, dy_out = g.linearize_data(x,y,None)
+        data_in = Data1D(x=x, y=y)
+        data_out = g.linearize_data(data_in)
+        x_out, y_out, dy_out = data_out.x, data_out.y, data_out.dy
         self.assertEqual(len(x_out), 3)
         self.assertEqual(len(y_out), 3)
@@ -261,13 +265,11 @@
 class TestDataExtraLowSlit(unittest.TestCase):
     """
-        Generate a Guinier distribution and verify that the extrapolation
-        produce the correct ditribution. Tested if the data generated by the 
-        invariant calculator is correct
-    """
-    
-    def setUp(self):
-        """
-            Generate a Guinier distribution. After extrapolating, we will
-            verify that we obtain the scale and rg parameters
+        for a smear data, test that the fitting go through 
+        reel data for the 2 first points
+    """
+    def setUp(self):
+        """
+           Reel data containing slit smear information
+           .Use 2 points of data to fit with power_law when exptrapolating
         """
         list = Loader().load("latex_smeared.xml")
@@ -275,4 +277,5 @@
         self.data.dxl = list[0].dxl
         self.data.dxw = list[0].dxw
+        self.npts = 2
         
     def test_low_q(self):
@@ -283,8 +286,8 @@
         inv = invariant.InvariantCalculator(data=self.data)
         # Set the extrapolation parameters for the low-Q range
-        inv.set_extrapolation(range='low', npts=20, function='guinier')
-        
-        self.assertEqual(inv._low_extrapolation_npts, 20)
-        self.assertEqual(inv._low_extrapolation_function.__class__, invariant.Guinier)
+        inv.set_extrapolation(range='low', npts=self.npts, function='power_law')
+        
+        self.assertEqual(inv._low_extrapolation_npts, self.npts)
+        self.assertEqual(inv._low_extrapolation_function.__class__, invariant.PowerLaw)
         
         # Data boundaries for fiiting
@@ -298,5 +301,4 @@
                           power=inv._low_extrapolation_power)
       
-        
         qstar = inv.get_qstar(extrapolation='low')
         reel_y = self.data.y
@@ -304,11 +306,227 @@
         #low data . expect the fit engine to have been already called and the guinier
         # to have the radius and the scale fitted
-        
-        test_y = inv._low_extrapolation_function.evaluate_model(x=self.data.x)
-        for i in range(len(self.data.x)):
+        test_y = inv._low_extrapolation_function.evaluate_model(x=self.data.x[:inv._low_extrapolation_npts])
+        #Check any points generated from the reel data and the extrapolation have
+        #very close value
+        self.assert_(len(test_y))== len(reel_y[:inv._low_extrapolation_npts])
+        for i in range(inv._low_extrapolation_npts):
+            value  = math.fabs(test_y[i]-reel_y[i])/reel_y[i]
+            self.assert_(value < 0.001)
+        data_out_range, data_in_range= inv.get_extra_data_low(npts_in=None)
+            
+class TestDataExtraLowSlitGuinier(unittest.TestCase):
+    """
+        for a smear data, test that the fitting go through 
+        reel data for atleast the 2 first points
+    """
+    
+    def setUp(self):
+        """
+            Generate a Guinier distribution. After extrapolating, we will
+            verify that we obtain the scale and rg parameters
+        """
+        self.scale = 1.5
+        self.rg = 30.0
+        x = numpy.arange(0.0001, 0.1, 0.0001)
+        y = numpy.asarray([self.scale * math.exp( -(q*self.rg)**2 / 3.0 ) for q in x])
+        dy = y*.1
+        dxl = 0.117 * numpy.ones(len(x))
+        self.data = Data1D(x=x, y=y, dy=dy)
+        self.data.dxl = dxl
+        self.npts = len(x)-10
+        
+    def test_low_q(self):
+        """
+            Invariant with low-Q extrapolation with slit smear
+        """
+        # Create invariant object. Background and scale left as defaults.
+        inv = invariant.InvariantCalculator(data=self.data)
+        # Set the extrapolation parameters for the low-Q range
+        inv.set_extrapolation(range='low', npts=self.npts, function='guinier')
+        
+        self.assertEqual(inv._low_extrapolation_npts, self.npts)
+        self.assertEqual(inv._low_extrapolation_function.__class__, invariant.Guinier)
+        
+        # Data boundaries for fiiting
+        qmin = inv._data.x[0]
+        qmax = inv._data.x[inv._low_extrapolation_npts - 1]
+        
+        # Extrapolate the low-Q data
+        a, b = inv._fit(model=inv._low_extrapolation_function,
+                          qmin=qmin,
+                          qmax=qmax,
+                          power=inv._low_extrapolation_power)
+      
+        
+        qstar = inv.get_qstar(extrapolation='low')
+        reel_y = self.data.y
+        #Compution the y 's coming out of the invariant when computing extrapolated
+        #low data . expect the fit engine to have been already called and the guinier
+        # to have the radius and the scale fitted
+        test_y = inv._low_extrapolation_function.evaluate_model(x=self.data.x[:inv._low_extrapolation_npts])
+        self.assert_(len(test_y))== len(reel_y[:inv._low_extrapolation_npts])
+        
+        for i in range(inv._low_extrapolation_npts):
             value  = math.fabs(test_y[i]-reel_y[i])/reel_y[i]
             self.assert_(value < 0.001)
             
+    def test_low_data(self):
+        """
+            Invariant with low-Q extrapolation with slit smear
+        """
+        # Create invariant object. Background and scale left as defaults.
+        inv = invariant.InvariantCalculator(data=self.data)
+        # Set the extrapolation parameters for the low-Q range
+        inv.set_extrapolation(range='low', npts=self.npts, function='guinier')
+        
+        self.assertEqual(inv._low_extrapolation_npts, self.npts)
+        self.assertEqual(inv._low_extrapolation_function.__class__, invariant.Guinier)
+        
+        # Data boundaries for fiiting
+        qmin = inv._data.x[0]
+        qmax = inv._data.x[inv._low_extrapolation_npts - 1]
+        
+        # Extrapolate the low-Q data
+        a, b = inv._fit(model=inv._low_extrapolation_function,
+                          qmin=qmin,
+                          qmax=qmax,
+                          power=inv._low_extrapolation_power)
+      
+        
+        qstar = inv.get_qstar(extrapolation='low')
+        reel_y = self.data.y
+        #Compution the y 's coming out of the invariant when computing extrapolated
+        #low data . expect the fit engine to have been already called and the guinier
+        # to have the radius and the scale fitted
+        data_out_range, data_in_range= inv.get_extra_data_low() 
+        test_y = data_in_range.y
+        self.assert_(len(test_y))== len(reel_y[:inv._low_extrapolation_npts])
+        for i in range(inv._low_extrapolation_npts):
+            value  = math.fabs(test_y[i]-reel_y[i])/reel_y[i]
+            self.assert_(value < 0.001)    
+                    
+        data_out_range, data_in_range= inv.get_extra_data_low(npts_in= 2, nsteps=10,
+                                                               q_start= 1e-4) 
+        test_y = data_in_range.y
+        self.assert_(len(test_y))== len(reel_y[:2])
+        for i in range(2):
+            value  = math.fabs(test_y[i]-reel_y[i])/reel_y[i]
+            self.assert_(value < 0.001) 
+        #test the data out of range          
+        test_out_y = data_out_range.y
+        self.assertEqual(len(test_out_y), 10)             
             
+class TestDataExtraHighSlitPowerLaw(unittest.TestCase):
+    """
+        for a smear data, test that the fitting go through 
+        reel data for atleast the 2 first points
+    """
+    
+    def setUp(self):
+        """
+            Generate a Guinier distribution. After extrapolating, we will
+            verify that we obtain the scale and rg parameters
+        """
+        self.scale = 1.5
+        self.m = 3.0
+        x = numpy.arange(0.0001, 0.1, 0.0001)
+        y = numpy.asarray([self.scale * math.pow(q ,-1.0*self.m) for q in x])                
+        dy = y*.1
+        self.data = Data1D(x=x, y=y, dy=dy)
+        dxl = 0.117 * numpy.ones(len(x))
+        self.data.dxl = dxl
+        self.npts = 20
+        
+    def test_high_q(self):
+        """
+            Invariant with high-Q extrapolation with slit smear
+        """
+        # Create invariant object. Background and scale left as defaults.
+        inv = invariant.InvariantCalculator(data=self.data)
+        # Set the extrapolation parameters for the low-Q range
+        inv.set_extrapolation(range='high', npts=self.npts, function='power_law')
+        
+        self.assertEqual(inv._high_extrapolation_npts, self.npts)
+        self.assertEqual(inv._high_extrapolation_function.__class__, invariant.PowerLaw)
+        
+        # Data boundaries for fiiting
+        xlen = len(self.data.x)
+        start =  xlen - inv._high_extrapolation_npts
+        qmin = inv._data.x[start]
+        qmax = inv._data.x[xlen-1]
+        
+        # Extrapolate the high-Q data
+        a, b = inv._fit(model=inv._high_extrapolation_function,
+                          qmin=qmin,
+                          qmax=qmax,
+                          power=inv._high_extrapolation_power)
+      
+        
+        qstar = inv.get_qstar(extrapolation='high')
+        reel_y = self.data.y
+        #Compution the y 's coming out of the invariant when computing extrapolated
+        #low data . expect the fit engine to have been already called and the power law
+        # to have the radius and the scale fitted
+       
+        
+        test_y = inv._high_extrapolation_function.evaluate_model(x=self.data.x[start: ])
+        self.assert_(len(test_y))== len(reel_y[start:])
+        
+        for i in range(len(self.data.x[start:])):
+            value  = math.fabs(test_y[i]-reel_y[start+i])/reel_y[start+i]
+            self.assert_(value < 0.001)
+            
+    def test_high_data(self):
+        """
+            Invariant with low-Q extrapolation with slit smear
+        """
+        # Create invariant object. Background and scale left as defaults.
+        inv = invariant.InvariantCalculator(data=self.data)
+        # Set the extrapolation parameters for the low-Q range
+        inv.set_extrapolation(range='high', npts=self.npts, function='power_law')
+        
+        self.assertEqual(inv._high_extrapolation_npts, self.npts)
+        self.assertEqual(inv._high_extrapolation_function.__class__, invariant.PowerLaw)
+        
+        # Data boundaries for fiiting
+        xlen = len(self.data.x)
+        start =  xlen - inv._high_extrapolation_npts
+        qmin = inv._data.x[start]
+        qmax = inv._data.x[xlen-1]
+        
+        # Extrapolate the high-Q data
+        a, b = inv._fit(model=inv._high_extrapolation_function,
+                          qmin=qmin,
+                          qmax=qmax,
+                          power=inv._high_extrapolation_power)
+      
+        
+        qstar = inv.get_qstar(extrapolation='high')
+        reel_y = self.data.y
+        #Compution the y 's coming out of the invariant when computing extrapolated
+        #low data . expect the fit engine to have been already called and the power law
+        # to have the radius and the scale fitted
+       
+        data_out_range, data_in_range= inv.get_extra_data_high() 
+        test_y = data_in_range.y
+        self.assert_(len(test_y))== len(reel_y[start:])
+        temp = reel_y[start:]
+        
+        for i in range(len(self.data.x[start:])):
+            value  = math.fabs(test_y[i]- temp[i])/temp[i]
+            self.assert_(value < 0.001)    
                     
-            
+        data_out_range, data_in_range= inv.get_extra_data_high(npts_in=5, nsteps=10,
+                                                               q_end= 2) 
+        test_y = data_in_range.y
+        self.assert_(len(test_y)==5)
+        temp = reel_y[start:start+5]
+        
+        for i in range(len(self.data.x[start:start+5])):
+          
+            value  = math.fabs(test_y[i]- temp[i])/temp[i]
+            self.assert_(value < 0.06)    
+        #test the data out of range          
+        test_out_y = data_out_range.y
+        self.assertEqual(len(test_out_y), 10)             
+                      
Index: Invariant/test/utest_use_cases.py
===================================================================
--- Invariant/test/utest_use_cases.py	(revision aafa962bf871a37b5ba098610635d93c7a8f200f)
+++ Invariant/test/utest_use_cases.py	(revision 76c17272262699f8d86f9ceaf30f7f02c1521f0a)
@@ -326,5 +326,5 @@
         # Test results
         self.assertAlmostEquals(qstar, 4.1539e-4, 2)
-        self.assertAlmostEquals(v, 0.032164596, 3)
+        self.assertAlmostEquals(v, 0.032164596, 2)
         self.assertAlmostEquals(s , 941.7452, 3)
         
