Changes in src/sas/sascalc/dataloader/data_info.py [4fdcc65:e090ba90] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/data_info.py
r4fdcc65 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): … … 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 807 raise ValueError(msg) … … 954 957 _str += "Data:\n" 955 958 _str += " Type: %s\n" % self.__class__.__name__ 956 _str += " X-axis: %s\t[%s]\n" % (self._xaxis, self._xunit) 957 _str += " Y-axis: %s\t[%s]\n" % (self._yaxis, self._yunit) 959 _str += " X- & Y-axis: %s\t[%s]\n" % (self._yaxis, self._yunit) 958 960 _str += " Z-axis: %s\t[%s]\n" % (self._zaxis, self._zunit) 959 961 _str += " Length: %g \n" % (len(self.data)) … … 984 986 qx_data=qx_data, qy_data=qy_data, 985 987 q_data=q_data, mask=mask) 986 987 clone._xaxis = self._xaxis988 clone._yaxis = self._yaxis989 clone._zaxis = self._zaxis990 clone._xunit = self._xunit991 clone._yunit = self._yunit992 clone._zunit = self._zunit993 clone.x_bins = self.x_bins994 clone.y_bins = self.y_bins995 988 996 989 clone.title = self.title … … 1032 1025 raise ValueError(msg) 1033 1026 for ind in range(len(self.data)): 1034 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: 1035 1028 msg = "Incompatible data sets: qx-values do not match: %s %s" % (self.qx_data[ind], other.qx_data[ind]) 1036 1029 raise ValueError(msg) 1037 if math.fabs((self.qy_data[ind] - other.qy_data[ind])/self.qy_data[ind]) >TOLERANCE:1030 if fabs(self.qy_data[ind] - other.qy_data[ind]) > fabs(self.qy_data[ind])*TOLERANCE: 1038 1031 msg = "Incompatible data sets: qy-values do not match: %s %s" % (self.qy_data[ind], other.qy_data[ind]) 1039 1032 raise ValueError(msg) … … 1163 1156 def combine_data_info_with_plottable(data, datainfo): 1164 1157 """ 1165 A function that combines the DataInfo data in self.current_datainto with a 1166 plottable_1D or 2D data object. 1158 A function that combines the DataInfo data in self.current_datainto with a plottable_1D or 2D data object. 1167 1159 1168 1160 :param data: A plottable_1D or plottable_2D data object … … 1182 1174 final_dataset.yaxis(data._yaxis, data._yunit) 1183 1175 elif isinstance(data, plottable_2D): 1184 final_dataset = Data2D(data.data, data.err_data, data.qx_data, 1185 data.qy_data, data.q_data, data.mask, 1186 data.dqx_data, data.dqy_data) 1176 final_dataset = Data2D(data.data, data.err_data, data.qx_data, data.qy_data, data.q_data, 1177 data.mask, data.dqx_data, data.dqy_data) 1187 1178 final_dataset.xaxis(data._xaxis, data._xunit) 1188 1179 final_dataset.yaxis(data._yaxis, data._yunit) 1189 1180 final_dataset.zaxis(data._zaxis, data._zunit) 1190 final_dataset.y_bins = data.y_bins 1191 final_dataset.x_bins = data.x_bins 1181 if len(data.data.shape) == 2: 1182 n_rows, n_cols = data.data.shape 1183 final_dataset.y_bins = data.qy_data[0::int(n_cols)] 1184 final_dataset.x_bins = data.qx_data[:int(n_cols)] 1192 1185 else: 1193 return_string = ("Should Never Happen: _combine_data_info_with_plottabl" 1194 "e input is not a plottable1d or plottable2d data " 1195 "object") 1186 return_string = "Should Never Happen: _combine_data_info_with_plottable input is not a plottable1d or " + \ 1187 "plottable2d data object" 1196 1188 return return_string 1197 1189
Note: See TracChangeset
for help on using the changeset viewer.