Changes in src/sas/sascalc/dataloader/data_info.py [e090ba90:deaa0c6] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/data_info.py
re090ba90 rdeaa0c6 26 26 import numpy as np 27 27 import math 28 from math import fabs29 28 30 29 class plottable_1D(object): … … 657 656 return self._perform_operation(other, operation) 658 657 659 def __ truediv__(self, other):658 def __div__(self, other): 660 659 """ 661 660 Divided a data set by another … … 668 667 return a/b 669 668 return self._perform_operation(other, operation) 670 __div__ = __truediv__ 671 672 def __rtruediv__(self, other): 669 670 def __rdiv__(self, other): 673 671 """ 674 672 Divided a data set by another … … 681 679 return b/a 682 680 return self._perform_operation(other, operation) 683 __rdiv__ = __rtruediv__684 681 685 682 def __or__(self, other): … … 719 716 self.y_unit = '1/cm' 720 717 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') 722 719 723 720 def __str__(self): … … 799 796 len(self.y) != len(other.y): 800 797 msg = "Unable to perform operation: data length are not equal" 801 raise ValueError (msg)798 raise ValueError, msg 802 799 # Here we could also extrapolate between data points 803 800 TOLERANCE = 0.01 804 801 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: 806 803 msg = "Incompatible data sets: x-values do not match" 807 raise ValueError (msg)804 raise ValueError, msg 808 805 809 806 # Check that the other data set has errors, otherwise … … 879 876 if not isinstance(other, Data1D): 880 877 msg = "Unable to perform operation: different types of data set" 881 raise ValueError (msg)878 raise ValueError, msg 882 879 return True 883 880 … … 951 948 952 949 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" 954 951 955 952 def __str__(self): … … 1023 1020 len(self.qy_data) != len(other.qy_data): 1024 1021 msg = "Unable to perform operation: data length are not equal" 1025 raise ValueError (msg)1022 raise ValueError, msg 1026 1023 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: 1028 1025 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: 1031 1028 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 1033 1030 1034 1031 # Check that the scales match … … 1111 1108 if not isinstance(other, Data2D): 1112 1109 msg = "Unable to perform operation: different types of data set" 1113 raise ValueError (msg)1110 raise ValueError, msg 1114 1111 return True 1115 1112
Note: See TracChangeset
for help on using the changeset viewer.