Changeset 0261bc1 in sasview
- Timestamp:
- Nov 20, 2017 5:55:30 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:
- f1ec901
- Parents:
- 6a3e1fe
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
setup.py
rfa81e94 r0261bc1 386 386 "src", "sas", "qtgui", "Perspectives", "Inversion", "UI") 387 387 packages.extend(["sas.qtgui.Perspectives.Inversion", "sas.qtgui.Perspectives.Inversion.UI"]) 388 389 package_dir["sas.qtgui.Perspectives.Corfunc"] = os.path.join( 390 "src", "sas", "qtgui", "Perspectives", "Corfunc") 391 package_dir["sas.qtgui.Perspectives.Corfunc.UI"] = os.path.join( 392 "src", "sas", "qtgui", "Perspectives", "Corfunc", "UI") 393 packages.extend(["sas.qtgui.Perspectives.Corfunc", "sas.qtgui.Perspectives.Corfunc.UI"]) 388 394 389 395 ## Plotting -
src/sas/qtgui/GUITests.py
r7c487846 r0261bc1 82 82 # Main window 83 83 unittest.makeSuite(DataExplorerTest.DataExplorerTest, 'test'), 84 85 unittest.makeSuite(GuiUtilsTest.GuiUtilsTest, 'test'),86 84 unittest.makeSuite(DroppableDataLoadWidgetTest.DroppableDataLoadWidgetTest, 'test'), 87 85 unittest.makeSuite(MainWindowTest.MainWindowTest, 'test'), … … 91 89 92 90 # Utilities 93 unittest.makeSuite(TestUtilsTest.TestUtilsTest, 'test'), 94 unittest.makeSuite(SasviewLoggerTest.SasviewLoggerTest, 'test'), 91 unittest.makeSuite(TestUtilsTest.TestUtilsTest, 'test'), 92 unittest.makeSuite(SasviewLoggerTest.SasviewLoggerTest, 'test'), 93 unittest.makeSuite(GuiUtilsTest.GuiUtilsTest, 'test'), 94 unittest.makeSuite(GuiUtilsTest.DoubleValidatorTest, 'test'), 95 unittest.makeSuite(GuiUtilsTest.HashableStandardItemTest, 'test'), 95 96 96 97 # Calculators -
src/sas/qtgui/MainWindow/DataManager.py
rb3e8629 r0261bc1 126 126 rename data 127 127 """ 128 ## name of the data allow to differentiate data when plotted 129 name = GuiUtils.parseName(name=name, expression="_") 128 # name of the data allow to differentiate data when plotted 129 try: 130 name = GuiUtils.parseName(name=name, expression="_") 131 except TypeError: 132 # bad name sent to rename 133 return None 130 134 131 135 max_char = name.find("[") -
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
r7c487846 r0261bc1 591 591 try: 592 592 value = GuiUtils.toDouble(item.text()) 593 except ValueError:593 except TypeError: 594 594 # Can't be converted properly, bring back the old value and exit 595 595 return … … 606 606 try: 607 607 value = GuiUtils.toDouble(item.text()) 608 except ValueError:608 except TypeError: 609 609 # Can't be converted properly, bring back the old value and exit 610 610 return … … 639 639 try: 640 640 value = GuiUtils.toDouble(item.text()) 641 except ValueError:641 except TypeError: 642 642 # Unparsable field 643 643 return … … 1310 1310 try: 1311 1311 value = GuiUtils.toDouble(item.text()) 1312 except ValueError:1312 except TypeError: 1313 1313 # Unparsable field 1314 1314 return -
src/sas/qtgui/Perspectives/Inversion/DMaxExplorerWidget.py
r6a3e1fe r0261bc1 45 45 self.setupUi(self) 46 46 47 self.setWindowTitle("Dâ ââ Explorer")47 self.setWindowTitle("Dââ Explorer") 48 48 49 49 self.pr_state = pr_state -
src/sas/qtgui/Utilities/GuiUtils.py
r6a3e1fe r0261bc1 271 271 """ 272 272 def __init__(self, parent=None): 273 super( QtGui.QStandardItem, self).__init__()273 super(HashableStandardItem, self).__init__() 274 274 275 275 def __hash__(self): … … 277 277 #return hash(self.__init__) 278 278 return 0 279 280 def clone(self): 281 ''' Assure __hash__ is cloned as well''' 282 clone = super(HashableStandardItem, self).clone() 283 clone.__hash__ = self.__hash__ 284 return clone 279 285 280 286 … … 561 567 with open(path,'w') as out: 562 568 has_errors = True 563 if data.dy is None or not data.dy :569 if data.dy is None or not data.dy.any(): 564 570 has_errors = False 565 571 # Sanity check … … 571 577 has_errors = False 572 578 if has_errors: 573 if data.dx is not None and data.dx :579 if data.dx is not None and data.dx.any(): 574 580 out.write("<X> <Y> <dY> <dX>\n") 575 581 else: … … 580 586 for i in range(len(data.x)): 581 587 if has_errors: 582 if data.dx is not None and data.dx :588 if data.dx is not None and data.dx.any(): 583 589 if data.dx[i] is not None: 584 590 out.write("%g %g %g %g\n" % (data.x[i], … … 857 863 return value[0] 858 864 else: 859 raise ValueError865 raise TypeError 860 866 861 867 class DoubleValidator(QtGui.QDoubleValidator): … … 867 873 Return invalid for commas 868 874 """ 869 if (',' in input):875 if input is not None and ',' in input: 870 876 return (QtGui.QValidator.Invalid, input, pos) 871 877 return super(DoubleValidator, self).validate(input, pos) … … 875 881 Correct (remove) potential preexisting content 876 882 """ 877 QtGui.QDoubleValidator.fixup(input)883 super(DoubleValidator, self).fixup(input) 878 884 input = input.replace(",", "") 879 885 -
src/sas/qtgui/Utilities/UnitTesting/GuiUtilsTest.py
r53c771e r0261bc1 414 414 self.assertEqual(yscale, "log") 415 415 416 def testParseName(self): 417 '''test parse out a string from the beinning of a string''' 418 # good input 419 value = "_test" 420 self.assertEqual(parseName(value, '_'), 'test') 421 value = "____test____" 422 self.assertEqual(parseName(value, '_'), '___test____') 423 self.assertEqual(parseName(value, '___'), '_test____') 424 self.assertEqual(parseName(value, 'test'), '____test____') 425 # bad input 426 with self.assertRaises(TypeError): 427 parseName(value, None) 428 with self.assertRaises(TypeError): 429 parseName(None, '_') 430 value = [] 431 with self.assertRaises(TypeError): 432 parseName(value, '_') 433 value = 1.44 434 with self.assertRaises(TypeError): 435 parseName(value, 'p') 436 value = 100 437 with self.assertRaises(TypeError): 438 parseName(value, 'p') 439 440 def testToDouble(self): 441 '''test homemade string-> double converter''' 442 #good values 443 value = "1" 444 self.assertEqual(toDouble(value), 1.0) 445 value = "1.2" 446 # has to be AlmostEqual due to numerical rounding 447 self.assertAlmostEqual(toDouble(value), 1.2, 6) 448 value = "2,1" 449 self.assertAlmostEqual(toDouble(value), 2.1, 6) 450 451 # bad values 452 value = None 453 with self.assertRaises(TypeError): 454 toDouble(value) 455 value = "MyDouble" 456 with self.assertRaises(TypeError): 457 toDouble(value) 458 value = [1,2.2] 459 with self.assertRaises(TypeError): 460 toDouble(value) 461 462 463 class DoubleValidatorTest(unittest.TestCase): 464 """ Test the validator for floats """ 465 def setUp(self): 466 '''Create the validator''' 467 self.validator = DoubleValidator() 468 469 def tearDown(self): 470 '''Destroy the validator''' 471 self.validator = None 472 473 def testValidateGood(self): 474 """Test a valid float """ 475 QtCore.QLocale.setDefault(QtCore.QLocale('en_US')) 476 float_good = "170" 477 self.assertEqual(self.validator.validate(float_good, 1)[0], QtGui.QValidator.Acceptable) 478 float_good = "170.11" 479 ## investigate: a double returns Invalid here! 480 ##self.assertEqual(self.validator.validate(float_good, 1)[0], QtGui.QValidator.Acceptable) 481 float_good = "17e2" 482 self.assertEqual(self.validator.validate(float_good, 1)[0], QtGui.QValidator.Acceptable) 483 484 def testValidateBad(self): 485 """Test a bad float """ 486 float_bad = None 487 self.assertEqual(self.validator.validate(float_bad, 1)[0], QtGui.QValidator.Intermediate) 488 float_bad = [1] 489 with self.assertRaises(TypeError): 490 self.validator.validate(float_bad, 1) 491 float_bad = "1,3" 492 self.assertEqual(self.validator.validate(float_bad, 1)[0], QtGui.QValidator.Invalid) 493 494 def notestFixup(self): 495 """Fixup of a float""" 496 float_to_fixup = "1,3" 497 self.validator.fixup(float_to_fixup) 498 self.assertEqual(float_to_fixup, "13") 499 416 500 417 501 class FormulaValidatorTest(unittest.TestCase): … … 434 518 435 519 def testValidateBad(self): 436 """Test a 520 """Test an invalid Formula """ 437 521 formula_bad = "H24 %%%O12C4C6N2Pu" 438 522 self.assertRaises(self.validator.validate(formula_bad, 1)[0]) … … 442 526 self.assertEqual(self.validator.validate(formula_bad, 1)[0], QtGui.QValidator.Intermediate) 443 527 528 class HashableStandardItemTest(unittest.TestCase): 529 """ Test the reimplementation of QStandardItem """ 530 def setUp(self): 531 '''Create the validator''' 532 self.item = HashableStandardItem() 533 534 def tearDown(self): 535 '''Destroy the validator''' 536 self.item = None 537 538 def testHash(self): 539 '''assure the item returns hash''' 540 self.assertEqual(self.item.__hash__(), 0) 541 542 def testIndexing(self): 543 '''test that we can use HashableSI as an index''' 544 dictionary = {} 545 dictionary[self.item] = "wow!" 546 self.assertEqual(dictionary[self.item], "wow!") 547 548 def testClone(self): 549 '''let's see if we can clone the item''' 550 item_clone = self.item.clone() 551 self.assertEqual(item_clone.__hash__(), 0) 444 552 445 553 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.