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


Python PDFCalculator.envelopes方法代码示例

本文整理汇总了Python中diffpy.srreal.pdfcalculator.PDFCalculator.envelopes方法的典型用法代码示例。如果您正苦于以下问题:Python PDFCalculator.envelopes方法的具体用法?Python PDFCalculator.envelopes怎么用?Python PDFCalculator.envelopes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在diffpy.srreal.pdfcalculator.PDFCalculator的用法示例。


在下文中一共展示了PDFCalculator.envelopes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_picking_owned

# 需要导入模块: from diffpy.srreal.pdfcalculator import PDFCalculator [as 别名]
# 或者: from diffpy.srreal.pdfcalculator.PDFCalculator import envelopes [as 别名]
 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,代码行数:31,代码来源:testpdfenvelope.py

示例2: test_makePDFEnvelope

# 需要导入模块: from diffpy.srreal.pdfcalculator import PDFCalculator [as 别名]
# 或者: from diffpy.srreal.pdfcalculator.PDFCalculator import envelopes [as 别名]
 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,代码行数:35,代码来源:testpdfenvelope.py


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