Changeset 6fd4e36 in sasview for src/sas/qtgui/Perspectives/Fitting/UnitTesting
- Timestamp:
- Mar 28, 2017 6:53:29 AM (7 years ago)
- Branches:
- ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- 0268aed
- Parents:
- a9b568c
- Location:
- src/sas/qtgui/Perspectives/Fitting/UnitTesting
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingLogicTest.py
r351b53e r6fd4e36 104 104 data, False, None) 105 105 106 self.logic.new1DPlot(return_data=return_data)106 new_plot = self.logic.new1DPlot(return_data=return_data) 107 107 108 self.assertIsInstance( self.logic.data, Data1D)109 self.assertFalse( self.logic.data.is_data)110 self.assertEqual( self.logic.data.dy.size, 3)111 self.assertEqual( self.logic.data.title, "boop")112 self.assertEqual( self.logic.data.name, "boop [boop]")108 self.assertIsInstance(new_plot, Data1D) 109 self.assertFalse(new_plot.is_data) 110 self.assertEqual(new_plot.dy.size, 3) 111 self.assertEqual(new_plot.title, "boop") 112 self.assertEqual(new_plot.name, "boop [boop]") 113 113 114 114 def testNew2DPlot(self): … … 142 142 0.1, False, None) 143 143 144 self.logic.new2DPlot(return_data=return_data)144 new_plot = self.logic.new2DPlot(return_data=return_data) 145 145 146 self.assertIsInstance( self.logic.data, Data2D)147 self.assertFalse( self.logic.data.is_data)148 self.assertEqual( self.logic.data.title, "Analytical model 2D ")149 self.assertEqual( self.logic.data.name, "boop [boop]")146 self.assertIsInstance(new_plot, Data2D) 147 self.assertFalse(new_plot.is_data) 148 self.assertEqual(new_plot.title, "Analytical model 2D ") 149 self.assertEqual(new_plot.name, "boop [boop]") 150 150 151 151 -
src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingUtilitiesTest.py
rb1e36a3 r6fd4e36 3 3 from PyQt4 import QtGui 4 4 5 from sas.sasgui.guiframe.dataFitting import Data1D 6 from sas.sasgui.guiframe.dataFitting import Data2D 7 5 8 from UnitTesting.TestUtils import WarningTestNotImplemented 6 #from sasmodels.sasview_model import load_standard_models 9 7 10 from sasmodels import generate 8 11 from sasmodels import modelinfo … … 180 183 self.assertEqual(model.item(1).child(0).child(0,1).text(), "40.0") 181 184 185 def testCalculate1DChi2(self): 186 """ 187 Test the chi2 calculator for Data1D 188 """ 189 reference_data = Data1D(x=[0.1, 0.2], y=[0.0, 0.0]) 190 191 # 1. identical data 192 current_data = Data1D(x=[0.1, 0.2], y=[0.0, 0.0]) 193 194 chi = FittingUtilities.calculateChi2(reference_data, current_data) 195 196 # Should be zero 197 self.assertAlmostEqual(chi, 0.0, 8) 198 199 # 2. far data 200 current_data = Data1D(x=[0.1, 0.2], y=[200.0, 150.0]) 201 202 chi = FittingUtilities.calculateChi2(reference_data, current_data) 203 204 # Should not be zero 205 self.assertAlmostEqual(chi, 31250.0, 8) 206 207 # 3. Wrong data 208 current_data = Data1D(x=[0.1, 0.2], y=[200.0, 150.0, 200.0]) 209 chi = FittingUtilities.calculateChi2(reference_data, current_data) 210 # Should be None 211 self.assertIsNone(chi) 212 213 def testCalculate2DChi2(self): 214 """ 215 Test the chi2 calculator for Data2D 216 """ 217 reference_data = Data2D(image=[1.0, 2.0, 3.0], 218 err_image=[0.01, 0.02, 0.03], 219 qx_data=[0.1, 0.2, 0.3], 220 qy_data=[0.1, 0.2, 0.3]) 221 222 # 1. identical data 223 current_data = Data2D(image=[1.0, 2.0, 3.0], 224 err_image=[0.01, 0.02, 0.03], 225 qx_data=[0.1, 0.2, 0.3], 226 qy_data=[0.1, 0.2, 0.3]) 227 228 chi = FittingUtilities.calculateChi2(reference_data, current_data) 229 230 # Should be zero 231 self.assertAlmostEqual(chi, 0.0, 8) 232 233 # 2. far data 234 current_data = Data2D(image=[100.0, 200.0, 300.0], 235 err_image=[1.01, 2.02, 3.03], 236 qx_data=[0.1, 0.2, 0.3], 237 qy_data=[100.0, 200., 300.]) 238 239 chi = FittingUtilities.calculateChi2(reference_data, current_data) 240 241 # Should not be zero 242 self.assertAlmostEqual(chi, 9607.88, 2) 243 244 # 3. Wrong data 245 current_data = Data2D(image=[1.0, 2.0, 3.0], 246 err_image=[0.01, 0.02], 247 qx_data=[0.1, 0.2], 248 qy_data=[0.1, 0.2, 0.3]) 249 # Should throw 250 with self.assertRaises(ValueError): 251 chi = FittingUtilities.calculateChi2(reference_data, current_data) 252 182 253 if __name__ == "__main__": 183 254 unittest.main() -
src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py
r9934e48 r6fd4e36 215 215 self.assertFalse(self.widget.calculateQGridForModel.called) 216 216 217 # Let's set a dummy index on widget218 self.widget. _index = QtGui.QStandardItem()217 # Let's tell the widget that data has been loaded 218 self.widget.data_is_loaded = True 219 219 # Reset the sasmodel index 220 220 self.widget.cbModel.setCurrentIndex(1)
Note: See TracChangeset
for help on using the changeset viewer.