Changeset 2e3e959 in sasview
- Timestamp:
- Jan 13, 2017 4:28:30 AM (8 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:
- 239214f
- Parents:
- db5cd8d
- Location:
- src/sas/qtgui
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/LinearFit.py
r87cc73a r2e3e959 70 70 self.transform = transform 71 71 72 self.setFixedSize(self.minimumSizeHint()) 73 72 74 # connect Fit button 73 75 self.cmdFit.clicked.connect(self.fit) … … 79 81 assert(isinstance(label, basestring)) 80 82 self.lblRange.setText(label) 81 82 def a(self):83 return (float(self.txtA.text()), float(self.txtAerr.text()))84 85 def b(self):86 return (float(self.txtB.text()), float(self.txtBerr.text()))87 88 def chi(self):89 return float(self.txtChi2.text())90 83 91 84 def range(self): -
src/sas/qtgui/UI/LinearFitUI.ui
r570a58f9 r2e3e959 7 7 <x>0</x> 8 8 <y>0</y> 9 <width>4 13</width>10 <height>32 7</height>9 <width>439</width> 10 <height>324</height> 11 11 </rect> 12 12 </property> 13 13 <property name="sizePolicy"> 14 <sizepolicy hsizetype=" MinimumExpanding" vsizetype="MinimumExpanding">14 <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> 15 15 <horstretch>0</horstretch> 16 16 <verstretch>0</verstretch> … … 28 28 <widget class="QLabel" name="label"> 29 29 <property name="text"> 30 <string><html><head/><body><p>Perform fit for <span style=" font- style:italic;">y(x) = ax + b</span></p></body></html></string>30 <string><html><head/><body><p>Perform fit for <span style=" font-weight:600; font-style:italic;">y(x) = ax + b</span></p></body></html></string> 31 31 </property> 32 32 </widget> 33 33 </item> 34 34 <item row="1" column="0" colspan="2"> 35 <widget class="QGroupBox" name="groupBox_2"> 36 <property name="title"> 37 <string>Fit ranges</string> 38 </property> 39 <layout class="QGridLayout" name="gridLayout_3"> 40 <item row="0" column="0"> 41 <layout class="QGridLayout" name="gridLayout_2"> 42 <item row="0" column="1"> 43 <widget class="QLabel" name="label_9"> 44 <property name="text"> 45 <string>Min</string> 46 </property> 47 </widget> 48 </item> 49 <item row="0" column="2"> 50 <widget class="QLabel" name="label_10"> 51 <property name="text"> 52 <string>Max</string> 53 </property> 54 </widget> 55 </item> 56 <item row="1" column="0"> 57 <widget class="QLabel" name="label_8"> 58 <property name="text"> 59 <string>Range (linear scale)</string> 60 </property> 61 </widget> 62 </item> 63 <item row="1" column="1"> 64 <widget class="QLineEdit" name="txtRangeMin"> 65 <property name="toolTip"> 66 <string><html><head/><body><p>Minimum value on the x-axis for the plotted data.</p></body></html></string> 67 </property> 68 <property name="autoFillBackground"> 69 <bool>true</bool> 70 </property> 71 <property name="readOnly"> 72 <bool>true</bool> 73 </property> 74 </widget> 75 </item> 76 <item row="1" column="2"> 77 <widget class="QLineEdit" name="txtRangeMax"> 78 <property name="toolTip"> 79 <string><html><head/><body><p>Maximum value on the x-axis for the plotted data.</p></body></html></string> 80 </property> 81 <property name="autoFillBackground"> 82 <bool>true</bool> 83 </property> 84 <property name="readOnly"> 85 <bool>true</bool> 86 </property> 87 </widget> 88 </item> 89 <item row="2" column="0"> 90 <widget class="QLabel" name="lblRange"> 91 <property name="text"> 92 <string><html><head/><body><p>Fit range</p></body></html></string> 93 </property> 94 </widget> 95 </item> 96 <item row="2" column="1"> 97 <widget class="QLineEdit" name="txtFitRangeMin"> 98 <property name="toolTip"> 99 <string><html><head/><body><p>Enter the minimum value on the x-axis to be included in the fit.</p></body></html></string> 100 </property> 101 </widget> 102 </item> 103 <item row="2" column="2"> 104 <widget class="QLineEdit" name="txtFitRangeMax"> 105 <property name="toolTip"> 106 <string><html><head/><body><p>Enter the maximum value on the x-axis to be included in the fit.</p></body></html></string> 107 </property> 108 </widget> 109 </item> 110 </layout> 111 </item> 112 </layout> 113 </widget> 114 </item> 115 <item row="2" column="0" colspan="2"> 35 116 <widget class="QGroupBox" name="groupBox"> 36 117 <property name="title"> … … 134 215 </widget> 135 216 </item> 136 <item row="2" column="0" colspan="2">137 <widget class="QGroupBox" name="groupBox_2">138 <property name="title">139 <string>Fit ranges</string>140 </property>141 <layout class="QGridLayout" name="gridLayout_3">142 <item row="0" column="0">143 <layout class="QGridLayout" name="gridLayout_2">144 <item row="0" column="1">145 <widget class="QLabel" name="label_9">146 <property name="text">147 <string>Min</string>148 </property>149 </widget>150 </item>151 <item row="0" column="2">152 <widget class="QLabel" name="label_10">153 <property name="text">154 <string>Max</string>155 </property>156 </widget>157 </item>158 <item row="1" column="0">159 <widget class="QLabel" name="label_8">160 <property name="text">161 <string>Range (linear scale)</string>162 </property>163 </widget>164 </item>165 <item row="1" column="1">166 <widget class="QLineEdit" name="txtRangeMin">167 <property name="toolTip">168 <string><html><head/><body><p>Minimum value on the x-axis for the plotted data.</p></body></html></string>169 </property>170 <property name="readOnly">171 <bool>true</bool>172 </property>173 </widget>174 </item>175 <item row="1" column="2">176 <widget class="QLineEdit" name="txtRangeMax">177 <property name="toolTip">178 <string><html><head/><body><p>Maximum value on the x-axis for the plotted data.</p></body></html></string>179 </property>180 <property name="readOnly">181 <bool>true</bool>182 </property>183 </widget>184 </item>185 <item row="2" column="0">186 <widget class="QLabel" name="lblRange">187 <property name="text">188 <string><html><head/><body><p>Fit range</p></body></html></string>189 </property>190 </widget>191 </item>192 <item row="2" column="1">193 <widget class="QLineEdit" name="txtFitRangeMin">194 <property name="toolTip">195 <string><html><head/><body><p>Enter the minimum value on the x-axis to be included in the fit.</p></body></html></string>196 </property>197 </widget>198 </item>199 <item row="2" column="2">200 <widget class="QLineEdit" name="txtFitRangeMax">201 <property name="toolTip">202 <string><html><head/><body><p>Enter the maximum value on the x-axis to be included in the fit.</p></body></html></string>203 </property>204 </widget>205 </item>206 </layout>207 </item>208 </layout>209 </widget>210 </item>211 217 <item row="3" column="0" colspan="2"> 212 218 <widget class="QLabel" name="label_2"> 213 219 <property name="text"> 214 <string><html><head/><body><p><span style=" color:# ff0000;">WARNING! Resolution is NOT accounted for.<br/>Thus slit smeared data will give very wrong answers!</span></p></body></html></string>220 <string><html><head/><body><p><span style=" color:#000000;">Resolution is NOT accounted for.<br/>Slit smeared data will give very wrong answers!</span></p></body></html></string> 215 221 </property> 216 222 </widget> -
src/sas/qtgui/UI/SetGraphRangeUI.ui
rd3ca363 r2e3e959 19 19 <property name="windowTitle"> 20 20 <string>Set Graph Range</string> 21 </property> 22 <property name="windowIcon"> 23 <iconset resource="main_resources.qrc"> 24 <normaloff>:/res/ball.ico</normaloff>:/res/ball.ico</iconset> 21 25 </property> 22 26 <property name="modal"> … … 93 97 </layout> 94 98 </widget> 95 <resources/> 99 <resources> 100 <include location="main_resources.qrc"/> 101 </resources> 96 102 <connections> 97 103 <connection> -
src/sas/qtgui/UI/convert_all.sh
r9290b1a r2e3e959 1 1 # UI -> PY 2 2 for filename in *.ui; do 3 pyuic .bat$filename > "`basename "$filename" .ui`.py"3 pyuic4 $filename > "`basename "$filename" .ui`.py" 4 4 done 5 5 -
src/sas/qtgui/UI/convert_ui.sh
rf51ed67 r2e3e959 1 pyuic .bat$1.ui > $1.py1 pyuic4 $1.ui > $1.py -
src/sas/qtgui/UnitTesting/LinearFitTest.py
rb46f285 r2e3e959 4 4 5 5 from PyQt4 import QtGui 6 from PyQt4 import QtCore7 6 from mock import MagicMock 8 7 … … 10 9 import path_prepare 11 10 12 from UnitTesting.TestUtils import QtSignalSpy13 11 from sas.sasgui.guiframe.dataFitting import Data1D 14 12 import sas.qtgui.Plotter as Plotter … … 61 59 # Compare 62 60 self.assertItemsEqual(return_values[0], [1.0, 3.0]) 63 self.assertItemsEqual(return_values[1], [10.004054329087303, 12.030439848443539]) 61 self.assertAlmostEqual(return_values[1][0], 10.004054329, 6) 62 self.assertAlmostEqual(return_values[1][1], 12.030439848, 6) 64 63 65 64 # Set the log scale … … 69 68 # Compare 70 69 self.assertItemsEqual(return_values[0], [1.0, 3.0]) 71 self.assertItemsEqual(return_values[1], [9.9877329376711437, 11.843650824649025]) 70 self.assertAlmostEqual(return_values[1][0], 9.987732937, 6) 71 self.assertAlmostEqual(return_values[1][1], 11.84365082, 6) 72 72 73 73 def testOrigData(self): … … 81 81 82 82 self.assertItemsEqual(x, orig_x) 83 self.assertItemsEqual(y, orig_y) 84 self.assertItemsEqual(dy, orig_dy) 83 self.assertEqual(y[0], orig_y[0]) 84 self.assertAlmostEqual(y[1], orig_y[1], 8) 85 self.assertAlmostEqual(y[2], orig_y[2], 8) 86 self.assertEqual(dy[0], orig_dy[0]) 87 self.assertAlmostEqual(dy[1], orig_dy[1], 8) 88 self.assertAlmostEqual(dy[2], orig_dy[2], 8) 85 89 86 90 # x, y … … 107 111 108 112 self.assertItemsEqual(x, orig_x) 109 self.assertItemsEqual(y, orig_y) 110 self.assertItemsEqual(dy, orig_dy) 113 self.assertEqual(y[0], orig_y[0]) 114 self.assertAlmostEqual(y[1], orig_y[1], 8) 115 self.assertAlmostEqual(y[2], orig_y[2], 8) 116 self.assertEqual(dy[0], orig_dy[0]) 117 self.assertAlmostEqual(dy[1], orig_dy[1], 8) 118 self.assertAlmostEqual(dy[2], orig_dy[2], 8) 111 119 112 120 def testCheckFitValues(self): … … 114 122 # Good values 115 123 self.assertTrue(self.widget.checkFitValues(self.widget.txtFitRangeMin)) 116 self.assertEqual(self.widget.txtFitRangeMin.palette().color(10).name(), "#f0f0f0") 124 # Colors platform dependent 125 #self.assertEqual(self.widget.txtFitRangeMin.palette().color(10).name(), "#f0f0f0") 117 126 # Bad values 118 127 self.widget.x_is_log = True -
src/sas/qtgui/UnitTesting/PlotterTest.py
rdb5cd8d r2e3e959 14 14 from sas.sasgui.guiframe.dataFitting import Data2D 15 15 from UnitTesting.TestUtils import WarningTestNotImplemented 16 from sas.qtgui.LinearFit import LinearFit 17 from sas.qtgui.PlotProperties import PlotProperties 16 18 17 19 # Tested module … … 224 226 def testOnLinearFit(self): 225 227 """ Checks the response to LinearFit call """ 226 WarningTestNotImplemented() 228 self.plotter.plot(self.data) 229 self.plotter.show() 230 QtGui.QDialog.exec_ = MagicMock(return_value=QtGui.QDialog.Accepted) 231 232 # Just this one plot 233 self.assertEqual(len(self.plotter.plot_dict.keys()), 1) 234 self.plotter.onLinearFit(1) 235 236 # Check that exec_ got called 237 self.assertTrue(QtGui.QDialog.exec_.called) 227 238 228 239 def testOnRemovePlot(self): 229 240 """ Assure plots get removed when requested """ 230 WarningTestNotImplemented() 241 # Add two plots 242 self.plotter.show() 243 self.plotter.plot(self.data) 244 data2 = Data1D(x=[1.0, 2.0, 3.0], 245 y=[11.0, 12.0, 13.0], 246 dx=[0.1, 0.2, 0.3], 247 dy=[0.1, 0.2, 0.3]) 248 data2.title="Test data 2" 249 data2.name="Test name 2" 250 data2.id = 2 251 self.plotter.plot(data2) 252 253 # Assure the plotter window is visible 254 self.assertTrue(self.plotter.isVisible()) 255 256 # Assure we have two sets 257 self.assertEqual(len(self.plotter.plot_dict.keys()), 2) 258 259 # Delete one set 260 self.plotter.onRemovePlot(2) 261 # Assure we have two sets 262 self.assertEqual(len(self.plotter.plot_dict.keys()), 1) 263 264 self.plotter.manager = MagicMock() 265 266 # Delete the remaining set 267 self.plotter.onRemovePlot(1) 268 # Assure we have no plots 269 self.assertEqual(len(self.plotter.plot_dict.keys()), 0) 270 # Assure the plotter window is closed 271 self.assertFalse(self.plotter.isVisible()) 272 231 273 232 274 def testRemovePlot(self): 233 275 """ Test plot removal """ 234 WarningTestNotImplemented() 276 # Add two plots 277 self.plotter.show() 278 self.plotter.plot(self.data) 279 data2 = Data1D(x=[1.0, 2.0, 3.0], 280 y=[11.0, 12.0, 13.0], 281 dx=[0.1, 0.2, 0.3], 282 dy=[0.1, 0.2, 0.3]) 283 data2.title="Test data 2" 284 data2.name="Test name 2" 285 data2.id = 2 286 data2._xaxis = "XAXIS" 287 data2._xunit = "furlong*fortnight^{-1}" 288 data2._yaxis = "YAXIS" 289 data2._yunit = "cake" 290 data2.hide_error = True 291 self.plotter.plot(data2) 292 293 # delete plot 1 294 self.plotter.removePlot(1) 295 296 # See that the labels didn't change 297 xl = self.plotter.ax.xaxis.label.get_text() 298 yl = self.plotter.ax.yaxis.label.get_text() 299 self.assertEqual(xl, "$XAXIS(furlong*fortnight^{-1})$") 300 self.assertEqual(yl, "$YAXIS(cake)$") 301 # The hide_error flag should also remain 302 self.assertTrue(self.plotter.plot_dict[2].hide_error) 235 303 236 304 def testOnToggleHideError(self): 237 305 """ Test the error bar toggle on plots """ 238 WarningTestNotImplemented() 306 # Add two plots 307 self.plotter.show() 308 self.plotter.plot(self.data) 309 data2 = Data1D(x=[1.0, 2.0, 3.0], 310 y=[11.0, 12.0, 13.0], 311 dx=[0.1, 0.2, 0.3], 312 dy=[0.1, 0.2, 0.3]) 313 data2.title="Test data 2" 314 data2.name="Test name 2" 315 data2.id = 2 316 data2._xaxis = "XAXIS" 317 data2._xunit = "furlong*fortnight^{-1}" 318 data2._yaxis = "YAXIS" 319 data2._yunit = "cake" 320 error_status = True 321 data2.hide_error = error_status 322 self.plotter.plot(data2) 323 324 # Reverse the toggle 325 self.plotter.onToggleHideError(2) 326 # See that the labels didn't change 327 xl = self.plotter.ax.xaxis.label.get_text() 328 yl = self.plotter.ax.yaxis.label.get_text() 329 self.assertEqual(xl, "$XAXIS(furlong*fortnight^{-1})$") 330 self.assertEqual(yl, "$YAXIS(cake)$") 331 # The hide_error flag should toggle 332 self.assertEqual(self.plotter.plot_dict[2].hide_error, not error_status) 239 333 240 334 def testOnFitDisplay(self): 241 335 """ Test the fit line display on the chart """ 242 WarningTestNotImplemented() 336 self.assertIsInstance(self.plotter.fit_result, Data1D) 337 self.assertEqual(self.plotter.fit_result.symbol, 13) 338 self.assertEqual(self.plotter.fit_result.name, "Fit") 339 340 # fudge some init data 341 fit_data = [[0.0,0.0], [5.0,5.0]] 342 # Call the method 343 self.plotter.plot = MagicMock() 344 self.plotter.onFitDisplay(fit_data) 345 self.assertTrue(self.plotter.plot.called) 346 # Look at arguments passed to .plot() 347 self.plotter.plot.assert_called_with(data=self.plotter.fit_result, 348 hide_error=True, marker='-') 243 349 244 350 def testReplacePlot(self): 245 351 """ Test the plot refresh functionality """ 246 WarningTestNotImplemented() 247 248 def testReplacePlot(self): 249 """ Test the plot refresh functionality """ 250 WarningTestNotImplemented(sys._getframe().f_code.co_name) 352 # Add original data 353 self.plotter.show() 354 self.plotter.plot(self.data) 355 # See the default labels 356 xl = self.plotter.ax.xaxis.label.get_text() 357 yl = self.plotter.ax.yaxis.label.get_text() 358 self.assertEqual(xl, "$()$") 359 self.assertEqual(yl, "$()$") 360 361 # Prepare new data 362 data2 = Data1D(x=[1.0, 2.0, 3.0], 363 y=[11.0, 12.0, 13.0], 364 dx=[0.1, 0.2, 0.3], 365 dy=[0.1, 0.2, 0.3]) 366 data2.title="Test data 2" 367 data2.name="Test name 2" 368 data2.id = 2 369 data2._xaxis = "XAXIS" 370 data2._xunit = "furlong*fortnight^{-1}" 371 data2._yaxis = "YAXIS" 372 data2._yunit = "cake" 373 error_status = True 374 data2.hide_error = error_status 375 376 # Replace data in plot 377 self.plotter.replacePlot(1, data2) 378 379 # See that the labels changed 380 xl = self.plotter.ax.xaxis.label.get_text() 381 yl = self.plotter.ax.yaxis.label.get_text() 382 self.assertEqual(xl, "$XAXIS(furlong*fortnight^{-1})$") 383 self.assertEqual(yl, "$YAXIS(cake)$") 384 # The hide_error flag should be as set 385 self.assertEqual(self.plotter.plot_dict[2].hide_error, error_status) 251 386 252 387 def testOnModifyPlot(self): 253 388 """ Test the functionality for changing plot properties """ 254 WarningTestNotImplemented() 389 # Prepare new data 390 data2 = Data1D(x=[1.0, 2.0, 3.0], 391 y=[11.0, 12.0, 13.0], 392 dx=[0.1, 0.2, 0.3], 393 dy=[0.1, 0.2, 0.3]) 394 data2.title="Test data 2" 395 data2.name="Test name 2" 396 data2.id = 2 397 data2.custom_color = None 398 data2.symbol = 1 399 data2.markersize = 11 400 401 self.plotter.plot(data2) 402 403 with patch('PlotProperties.PlotProperties') as mock: 404 instance = mock.return_value 405 QtGui.QDialog.exec_ = MagicMock(return_value=QtGui.QDialog.Accepted) 406 instance.symbol.return_value = 7 407 408 self.plotter.onModifyPlot(2) 409 410 #print self.plotter.plot_dict[2].symbol 411 255 412 256 413 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.