當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。