Changes in src/sas/sascalc/dataloader/data_info.py [deaa0c6:e090ba90] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/data_info.py
rdeaa0c6 re090ba90 26 26 import numpy as np 27 27 import math 28 from math import fabs 28 29 29 30 class plottable_1D(object): … … 656 657 return self._perform_operation(other, operation) 657 658 658 def __ div__(self, other):659 def __truediv__(self, other): 659 660 """ 660 661 Divided a data set by another … … 667 668 return a/b 668 669 return self._perform_operation(other, operation) 669 670 def __rdiv__(self, other): 670 __div__ = __truediv__ 671 672 def __rtruediv__(self, other): 671 673 """ 672 674 Divided a data set by another … … 679 681 return b/a 680 682 return self._perform_operation(other, operation) 683 __rdiv__ = __rtruediv__ 681 684 682 685 def __or__(self, other): … … 716 719 self.y_unit = '1/cm' 717 720 except: # the data is not recognized/supported, and the user is notified 718 raise (TypeError,'data not recognized, check documentation for supported 1D data formats')721 raise TypeError('data not recognized, check documentation for supported 1D data formats') 719 722 720 723 def __str__(self): … … 796 799 len(self.y) != len(other.y): 797 800 msg = "Unable to perform operation: data length are not equal" 798 raise ValueError , msg801 raise ValueError(msg) 799 802 # Here we could also extrapolate between data points 800 803 TOLERANCE = 0.01 801 804 for i in range(len(self.x)): 802 if math.fabs((self.x[i] - other.x[i])/self.x[i]) >TOLERANCE:805 if fabs(self.x[i] - other.x[i]) > self.x[i]*TOLERANCE: 803 806 msg = "Incompatible data sets: x-values do not match" 804 raise ValueError , msg807 raise ValueError(msg) 805 808 806 809 # Check that the other data set has errors, otherwise … … 876 879 if not isinstance(other, Data1D): 877 880 msg = "Unable to perform operation: different types of data set" 878 raise ValueError , msg881 raise ValueError(msg) 879 882 return True 880 883 … … 948 951 949 952 if len(self.detector) > 0: 950 raise RuntimeError , "Data2D: Detector bank already filled at init"953 raise RuntimeError("Data2D: Detector bank already filled at init") 951 954 952 955 def __str__(self): … … 1020 1023 len(self.qy_data) != len(other.qy_data): 1021 1024 msg = "Unable to perform operation: data length are not equal" 1022 raise ValueError , msg1025 raise ValueError(msg) 1023 1026 for ind in range(len(self.data)): 1024 if math.fabs((self.qx_data[ind] - other.qx_data[ind])/self.qx_data[ind]) >TOLERANCE:1027 if fabs(self.qx_data[ind] - other.qx_data[ind]) > fabs(self.qx_data[ind])*TOLERANCE: 1025 1028 msg = "Incompatible data sets: qx-values do not match: %s %s" % (self.qx_data[ind], other.qx_data[ind]) 1026 raise ValueError , msg1027 if math.fabs((self.qy_data[ind] - other.qy_data[ind])/self.qy_data[ind]) >TOLERANCE:1029 raise ValueError(msg) 1030 if fabs(self.qy_data[ind] - other.qy_data[ind]) > fabs(self.qy_data[ind])*TOLERANCE: 1028 1031 msg = "Incompatible data sets: qy-values do not match: %s %s" % (self.qy_data[ind], other.qy_data[ind]) 1029 raise ValueError , msg1032 raise ValueError(msg) 1030 1033 1031 1034 # Check that the scales match … … 1108 1111 if not isinstance(other, Data2D): 1109 1112 msg = "Unable to perform operation: different types of data set" 1110 raise ValueError , msg1113 raise ValueError(msg) 1111 1114 return True 1112 1115
Note: See TracChangeset
for help on using the changeset viewer.