Beispiel #1
0
 def test_type(self):
     """check PeakWidthModel.type
     """
     # this is a virtual method in the base class
     self.assertRaises(RuntimeError, PeakWidthModel().type)
     self.assertEqual('constant', self.pwconst.type())
     return
Beispiel #2
0
 def setUp(self):
     self.pwconst = PeakWidthModel.createByType('constant')
     self.pwconst.width = 2
     if self.tio2stru is None:
         self.tio2stru = loadDiffPyStructure('rutile.cif')
         self.tio2adpt = createStructureAdapter(self.tio2stru)
     return
 def setUp(self):
     self.pwconst = PeakWidthModel.createByType('constant')
     self.pwconst.width = 2
     if self.tio2stru is None:
         self.tio2stru = loadDiffPyStructure('rutile.cif')
         self.tio2adpt = createStructureAdapter(self.tio2stru)
     return
Beispiel #4
0
 def test_maxWidth(self):
     """check PeakWidthModel.maxWidth()
     """
     self.assertRaises(RuntimeError,
                       PeakWidthModel().maxWidth, self.tio2adpt, 0, 10)
     self.assertEqual(2.0, self.pwconst.maxWidth(self.tio2adpt, 0, 10))
     self.assertEqual(2.0, self.pwconst.maxWidth(self.tio2stru, 0, 10))
     return
 def test_getRegisteredTypes(self):
     """check PeakWidthModel.getRegisteredTypes
     """
     regtypes = PeakWidthModel.getRegisteredTypes()
     self.assertTrue(3 <= len(regtypes))
     self.assertTrue(regtypes.issuperset(
         ['constant', 'debye-waller', 'jeong']))
     return
Beispiel #6
0
 def test_getRegisteredTypes(self):
     """check PeakWidthModel.getRegisteredTypes
     """
     regtypes = PeakWidthModel.getRegisteredTypes()
     self.assertTrue(3 <= len(regtypes))
     self.assertTrue(
         regtypes.issuperset(['constant', 'debye-waller', 'jeong']))
     return
Beispiel #7
0
 def test_calculate(self):
     """check PeakWidthModel.calculate()
     """
     pwm = PeakWidthModel()
     bnds = self._genbonds(1, 2)
     self.assertRaises(RuntimeError, pwm.calculate, bnds)
     self.assertEqual(2.0, self.pwconst.calculate(bnds))
     return
Beispiel #8
0
 def test_calculate(self):
     """check PeakWidthModel.calculate()
     """
     pwm = PeakWidthModel()
     bnds = self.tio2adpt.createBondGenerator()
     self.assertRaises(RuntimeError, pwm.calculate, bnds)
     self.assertEqual(2.0, self.pwconst.calculate(bnds))
     return
Beispiel #9
0
 def test_create(self):
     """check PeakWidthModel.create
     """
     # this is a virtual method in the base class
     self.assertRaises(RuntimeError, PeakWidthModel().create)
     self.assertEqual('constant', self.pwconst.create().type())
     self.pwconst.width = 17
     self.assertEqual(0.0, self.pwconst.create().width)
     return
Beispiel #10
0
 def test_clone(self):
     """check PeakWidthModel.clone
     """
     # this is a virtual method in the base class
     self.assertRaises(RuntimeError, PeakWidthModel().clone)
     self.pwconst.width = 17
     pwc2 = self.pwconst.clone()
     self.assertEqual('constant', pwc2.type())
     self.assertEqual(17.0, pwc2.width)
     self.assertEqual(17.0, pwc2._getDoubleAttr('width'))
     return
Beispiel #11
0
 def test_ticker_override(self):
     """check PeakWidthModel.ticker override in a Python-derived class.
     """
     pwm = MyPWM()
     self.assertEqual(0, pwm.tcnt)
     et0 = pwm.ticker()
     self.assertEqual(1, pwm.tcnt)
     et1 = PeakWidthModel.ticker(pwm)
     self.assertEqual(1, pwm.tcnt)
     self.assertEqual(et0, et1)
     et0.click()
     self.assertEqual(et0, et1)
     # check that implicit ticker call from PDFCalculator is
     # handled by the Python ticker override.
     pc = PDFCalculator()
     pc.peakwidthmodel = pwm
     pc.ticker()
     self.assertEqual(2, pwm.tcnt)
     return
 def test_ticker_override(self):
     """check PeakWidthModel.ticker override in a Python-derived class.
     """
     pwm = MyPWM()
     self.assertEqual(0, pwm.tcnt)
     et0 = pwm.ticker()
     self.assertEqual(1, pwm.tcnt)
     et1 = PeakWidthModel.ticker(pwm)
     self.assertEqual(1, pwm.tcnt)
     self.assertEqual(et0, et1)
     et0.click()
     self.assertEqual(et0, et1)
     # check that implicit ticker call from PDFCalculator is
     # handled by the Python ticker override.
     pc = PDFCalculator()
     pc.peakwidthmodel = pwm
     pc.ticker()
     self.assertEqual(2, pwm.tcnt)
     return
 def ticker(self):
     self.tcnt += 1
     return PeakWidthModel.ticker(self)
 def __init__(self):
     PeakWidthModel.__init__(self)
     self._registerDoubleAttribute('pwmscale')
     return
Beispiel #15
0
 def __init__(self):
     PeakWidthModel.__init__(self)
     self._registerDoubleAttribute('pwmscale')
     return
Beispiel #16
0
 def ticker(self):
     self.tcnt += 1
     return PeakWidthModel.ticker(self)
Beispiel #17
0
 def tearDownClass(cls):
     assert "mypwm" not in PeakWidthModel.getRegisteredTypes()
     return