本文整理汇总了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
示例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