当前位置: 首页>>代码示例>>Python>>正文


Python pdfcalculator.PDFCalculator类代码示例

本文整理汇总了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
开发者ID:diffpy,项目名称:diffpy.srreal,代码行数:29,代码来源:testpdfenvelope.py

示例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
开发者ID:hjjvandam,项目名称:diffpy.srreal,代码行数:33,代码来源:testpdfenvelope.py

示例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
开发者ID:diffpy,项目名称:diffpy.srreal,代码行数:8,代码来源:testattributes.py

示例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
开发者ID:XiaohaoYang,项目名称:diffpy.srreal,代码行数:9,代码来源:testpdfcalculator.py

示例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
开发者ID:pavoljuhas,项目名称:diffpy.srreal,代码行数:10,代码来源:teststructureadapter.py

示例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
开发者ID:diffpy,项目名称:diffpy.srreal,代码行数:11,代码来源:testattributes.py

示例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
开发者ID:suwoonglee,项目名称:diffpy.srreal,代码行数:14,代码来源:teststructureadapter.py

示例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
开发者ID:pavoljuhas,项目名称:diffpy.srreal,代码行数:14,代码来源:teststructureadapter.py

示例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
开发者ID:diffpy,项目名称:diffpy.srreal,代码行数:16,代码来源:testpdfbaseline.py

示例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
开发者ID:pavoljuhas,项目名称:diffpy.srreal,代码行数:16,代码来源:testpdfcalcobjcryst.py

示例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
开发者ID:hjjvandam,项目名称:diffpy.srreal,代码行数:16,代码来源:testattributes.py

示例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
开发者ID:XiaohaoYang,项目名称:diffpy.srreal,代码行数:8,代码来源:testpdfcalculator.py

示例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
开发者ID:diffpy,项目名称:diffpy.srreal,代码行数:18,代码来源:testpdfcalcobjcryst.py

示例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
开发者ID:hjjvandam,项目名称:diffpy.srreal,代码行数:19,代码来源:testpeakprofile.py

示例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
开发者ID:hjjvandam,项目名称:diffpy.srreal,代码行数:19,代码来源:testpeakwidthmodel.py


注:本文中的diffpy.srreal.pdfcalculator.PDFCalculator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。