Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/dataloader/data_info.py

    re090ba90 rdeaa0c6  
    2626import numpy as np 
    2727import math 
    28 from math import fabs 
    2928 
    3029class plottable_1D(object): 
     
    657656        return self._perform_operation(other, operation) 
    658657 
    659     def __truediv__(self, other): 
     658    def __div__(self, other): 
    660659        """ 
    661660        Divided a data set by another 
     
    668667            return a/b 
    669668        return self._perform_operation(other, operation) 
    670     __div__ = __truediv__ 
    671  
    672     def __rtruediv__(self, other): 
     669 
     670    def __rdiv__(self, other): 
    673671        """ 
    674672        Divided a data set by another 
     
    681679            return b/a 
    682680        return self._perform_operation(other, operation) 
    683     __rdiv__ = __rtruediv__ 
    684681 
    685682    def __or__(self, other): 
     
    719716                self.y_unit = '1/cm' 
    720717        except: # the data is not recognized/supported, and the user is notified 
    721             raise TypeError('data not recognized, check documentation for supported 1D data formats') 
     718            raise(TypeError, 'data not recognized, check documentation for supported 1D data formats') 
    722719 
    723720    def __str__(self): 
     
    799796                len(self.y) != len(other.y): 
    800797                msg = "Unable to perform operation: data length are not equal" 
    801                 raise ValueError(msg) 
     798                raise ValueError, msg 
    802799            # Here we could also extrapolate between data points 
    803800            TOLERANCE = 0.01 
    804801            for i in range(len(self.x)): 
    805                 if fabs(self.x[i] - other.x[i]) > self.x[i]*TOLERANCE: 
     802                if math.fabs((self.x[i] - other.x[i])/self.x[i]) > TOLERANCE: 
    806803                    msg = "Incompatible data sets: x-values do not match" 
    807                     raise ValueError(msg) 
     804                    raise ValueError, msg 
    808805 
    809806            # Check that the other data set has errors, otherwise 
     
    879876        if not isinstance(other, Data1D): 
    880877            msg = "Unable to perform operation: different types of data set" 
    881             raise ValueError(msg) 
     878            raise ValueError, msg 
    882879        return True 
    883880 
     
    951948 
    952949        if len(self.detector) > 0: 
    953             raise RuntimeError("Data2D: Detector bank already filled at init") 
     950            raise RuntimeError, "Data2D: Detector bank already filled at init" 
    954951 
    955952    def __str__(self): 
     
    10231020                len(self.qy_data) != len(other.qy_data): 
    10241021                msg = "Unable to perform operation: data length are not equal" 
    1025                 raise ValueError(msg) 
     1022                raise ValueError, msg 
    10261023            for ind in range(len(self.data)): 
    1027                 if fabs(self.qx_data[ind] - other.qx_data[ind]) > fabs(self.qx_data[ind])*TOLERANCE: 
     1024                if math.fabs((self.qx_data[ind] - other.qx_data[ind])/self.qx_data[ind]) > TOLERANCE: 
    10281025                    msg = "Incompatible data sets: qx-values do not match: %s %s" % (self.qx_data[ind], other.qx_data[ind]) 
    1029                     raise ValueError(msg) 
    1030                 if fabs(self.qy_data[ind] - other.qy_data[ind]) > fabs(self.qy_data[ind])*TOLERANCE: 
     1026                    raise ValueError, msg 
     1027                if math.fabs((self.qy_data[ind] - other.qy_data[ind])/self.qy_data[ind]) > TOLERANCE: 
    10311028                    msg = "Incompatible data sets: qy-values do not match: %s %s" % (self.qy_data[ind], other.qy_data[ind]) 
    1032                     raise ValueError(msg) 
     1029                    raise ValueError, msg 
    10331030 
    10341031            # Check that the scales match 
     
    11111108        if not isinstance(other, Data2D): 
    11121109            msg = "Unable to perform operation: different types of data set" 
    1113             raise ValueError(msg) 
     1110            raise ValueError, msg 
    11141111        return True 
    11151112 
Note: See TracChangeset for help on using the changeset viewer.