本文整理汇总了Python中diffpy.srreal.pdfcalculator.PDFCalculator类的典型用法代码示例。如果您正苦于以下问题:Python PDFCalculator类的具体用法?Python PDFCalculator怎么用?Python PDFCalculator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PDFCalculator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_picking_owned
def test_picking_owned(self):
'''verify pickling of envelopes owned by PDF calculators.
'''
pbl = makePDFEnvelope('parabolaenvelope',
parabola_envelope, a=1, b=2, c=3)
pbl.a = 7
pbl.foobar = 'asdf'
pc = PDFCalculator()
pc.envelopes = (pbl,)
dbpc = DebyePDFCalculator()
dbpc.envelopes = (pbl,)
self.assertIs(pbl, pc.envelopes[0])
self.assertIs(pbl, dbpc.envelopes[0])
pc.addEnvelope(self.fscale)
dbpc.addEnvelope(self.fscale)
self.fscale.scale = 3.5
self.assertEqual(3.5, pc.scale)
self.assertEqual(3.5, dbpc.scale)
pc2 = pickle.loads(pickle.dumps(pc))
dbpc2 = pickle.loads(pickle.dumps(dbpc))
self.assertEqual(3.5, pc2.scale)
self.assertEqual(3.5, dbpc2.scale)
pblcopies = [pc2.getEnvelope("parabolaenvelope"),
dbpc2.getEnvelope("parabolaenvelope")]
for pbl2 in pblcopies:
self.assertEqual(7, pbl2.a)
self.assertEqual('asdf', pbl2.foobar)
self.assertEqual('parabolaenvelope', pbl2.type())
return
示例2: test_makePDFEnvelope
def test_makePDFEnvelope(self):
'''check the makePDFEnvelope wrapper.
'''
pbl = makePDFEnvelope('parabolaenvelope',
parabola_envelope, a=1, b=2, c=3)
self.assertEqual(3, pbl(0))
self.assertEqual(6, pbl(1))
self.assertEqual(11, pbl(2))
pbl.b = 0
self.assertEqual([7, 3, 28], map(pbl, [-2, 0, 5]))
pbl2 = pbl.clone()
self.assertEqual(1, pbl2.a)
self.assertEqual(0, pbl2.b)
self.assertEqual(3, pbl2.c)
self.assertEqual([7, 3, 28], map(pbl2, [-2, 0, 5]))
pbl3 = PDFEnvelope.createByType('parabolaenvelope')
self.assertEqual(1, pbl3.a)
self.assertEqual(2, pbl3.b)
self.assertEqual(3, pbl3.c)
pbl3.a = 0
pbl3.foo = 'asdf'
pbl3cp = cPickle.loads(cPickle.dumps(pbl3))
self.assertEqual(0, pbl3cp.a)
self.assertEqual('asdf', pbl3cp.foo)
pc = PDFCalculator()
pc.envelopes = (pbl2,)
pc2 = cPickle.loads(cPickle.dumps(pc))
pbl2cp = pc2.envelopes[0]
self.assertEqual('parabolaenvelope', pbl2cp.type())
self.assertEqual(1, pbl2cp.a)
self.assertEqual(0, pbl2cp.b)
self.assertEqual(3, pbl2cp.c)
return
示例3: test__setDoubleAttr
def test__setDoubleAttr(self):
"""check Attributes._setDoubleAttr()
"""
pdfc = PDFCalculator()
pdfc._setDoubleAttr('scale', 1.23)
self.assertFalse('scale' in pdfc.__dict__)
self.assertEqual(1.23, pdfc.scale)
return
示例4: test___init__
def test___init__(self):
"""check PDFCalculator.__init__()
"""
pdfc = PDFCalculator(qmin=13, rmin=4, rmax=99)
self.assertEqual(13, pdfc.qmin)
self.assertEqual(4, pdfc.rmin)
self.assertEqual(99, pdfc.rmax)
self.assertEqual(99, pdfc._getDoubleAttr('rmax'))
return
示例5: test__customPQConfig
def test__customPQConfig(self):
"""check if DerivedCls._customPQConfig gets called.
"""
self.assertEqual(0, self.adpt.cpqcount)
pc = PDFCalculator()
pc.setStructure(self.adpt)
self.assertEqual(1, self.adpt.cpqcount)
pc(self.adpt)
self.assertEqual(2, self.adpt.cpqcount)
return
示例6: test___getattr__
def test___getattr__(self):
"""check Attributes.__getattr__()
"""
a = Attributes()
self.assertRaises(AttributeError, getattr, a, 'invalid')
a.x = 11
self.assertEqual(11, a.x)
pdfc = PDFCalculator()
pdfc._setDoubleAttr('rmax', 12.34)
self.assertEqual(12.34, pdfc.rmax)
return
示例7: test_pickling
def test_pickling(self):
"""check pickling of DerivedCls instances.
"""
self.adpt.cpqcount = 1
adpt1 = cPickle.loads(cPickle.dumps(self.adpt))
self.failUnless(self.DerivedCls is type(adpt1))
self.failIf(self.adpt is adpt1)
self.assertEqual(1, adpt1.cpqcount)
pc = PDFCalculator()
pc.setStructure(adpt1)
self.assertEqual(2, adpt1.cpqcount)
pc(adpt1)
self.assertEqual(3, adpt1.cpqcount)
return
示例8: test_pickling
def test_pickling(self):
'''check pickling of DerivedCls instances.
'''
self.adpt.cpqcount = 1
adpt1 = cPickle.loads(cPickle.dumps(self.adpt))
self.assertTrue(self.DerivedCls is type(adpt1))
self.assertFalse(self.adpt is adpt1)
self.assertEqual(1, adpt1.cpqcount)
pc = PDFCalculator()
pc.setStructure(adpt1)
self.assertEqual(2, adpt1.cpqcount)
pc(adpt1)
self.assertEqual(3, adpt1.cpqcount)
return
示例9: test_picking_owned
def test_picking_owned(self):
'''verify pickling of PDFBaseline owned by PDF calculators.
'''
pbl = makePDFBaseline('parabolabaseline',
parabola_baseline, a=1, b=2, c=3)
pbl.a = 7
pbl.foobar = 'asdf'
pc = PDFCalculator()
pc.baseline = pbl
self.assertIs(pbl, pc.baseline)
pc2 = pickle.loads(pickle.dumps(pc))
pbl2 = pc2.baseline
self.assertEqual(7, pbl2.a)
self.assertEqual('asdf', pbl2.foobar)
self.assertEqual('parabolabaseline', pbl2.type())
return
示例10: _makePDFCalculator
def _makePDFCalculator(crst, cfgdict):
'''Return a PDFCalculator object evaluated for a pyobjcryst.Crystal crst.
'''
inpdfcalc = lambda kv: kv[0] not in ('biso', 'type')
pdfcargs = dict(filter(inpdfcalc, cfgdict.items()))
pdfc = PDFCalculator(**pdfcargs)
if 'biso' in cfgdict:
setbiso = lambda sc: sc.mpScattPow.SetBiso(cfgdict['biso'])
map(setbiso, crst.GetScatteringComponentList())
if 'type' in cfgdict:
pdfc.scatteringfactortable = cfgdict['type']
pdfc.eval(crst)
# avoid metadata override by PDFFitStructure
for k, v in pdfcargs.items():
setattr(pdfc, k, v)
return pdfc
示例11: test__namesOfWritableDoubleAttributes
def test__namesOfWritableDoubleAttributes(self):
"""check Attributes._namesOfDoubleAttributes()
"""
a = Attributes()
self.assertEqual(0, len(a._namesOfDoubleAttributes()))
a._registerDoubleAttribute('bar', lambda obj: 13)
self.assertEqual(13, a._getDoubleAttr('bar'))
self.assertEqual(13, a.bar)
self.assertEqual(1, len(a._namesOfDoubleAttributes()))
self.assertEqual(0, len(a._namesOfWritableDoubleAttributes()))
pdfc = PDFCalculator()
self.failUnless('extendedrmin' in pdfc._namesOfDoubleAttributes())
self.failUnless('extendedrmax' in pdfc._namesOfDoubleAttributes())
self.failIf('extendedrmin' in pdfc._namesOfWritableDoubleAttributes())
self.failIf('extendedrmax' in pdfc._namesOfWritableDoubleAttributes())
return
示例12: setUp
def setUp(self):
self.pdfcalc = PDFCalculator()
if not self.nickel:
type(self).nickel = loadDiffPyStructure('Ni.stru')
if not self.tio2rutile:
type(self).tio2rutile = (
loadDiffPyStructure('TiO2_rutile-fit.stru'))
return
示例13: _makePDFCalculator
def _makePDFCalculator(crst, cfgdict):
'''Return a PDFCalculator object evaluated for a pyobjcryst.Crystal crst.
'''
pdfcargs = {k : v for k, v in cfgdict.items()
if k not in ('biso', 'type')}
pdfc = PDFCalculator(**pdfcargs)
if 'biso' in cfgdict:
reg = crst.GetScatteringPowerRegistry()
for i in range(reg.GetNb()):
sp = reg.GetObj(i)
sp.SetBiso(cfgdict['biso'])
if 'type' in cfgdict:
pdfc.scatteringfactortable = cfgdict['type']
pdfc.eval(crst)
# avoid metadata override by PDFFitStructure
for k, v in pdfcargs.items():
setattr(pdfc, k, v)
return pdfc
示例14: test_ticker_override
def test_ticker_override(self):
"""check method override for PeakProfile.ticker in a derived class.
"""
pkf = MySawTooth()
self.assertEqual(0, pkf.tcnt)
et0 = pkf.ticker()
self.assertEqual(1, pkf.tcnt)
et1 = PeakProfile.ticker(pkf)
self.assertEqual(1, pkf.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.peakprofile = pkf
pc.ticker()
self.assertEqual(2, pkf.tcnt)
return
示例15: test_ticker_override
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