本文整理汇总了Python中diffpy.pdffit2.PdfFit.num_atoms方法的典型用法代码示例。如果您正苦于以下问题:Python PdfFit.num_atoms方法的具体用法?Python PdfFit.num_atoms怎么用?Python PdfFit.num_atoms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类diffpy.pdffit2.PdfFit
的用法示例。
在下文中一共展示了PdfFit.num_atoms方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestPdfFit
# 需要导入模块: from diffpy.pdffit2 import PdfFit [as 别名]
# 或者: from diffpy.pdffit2.PdfFit import num_atoms [as 别名]
class TestPdfFit(unittest.TestCase):
places = 6
def setUp(self):
self.P = PdfFit()
return
def tearDown(self):
del self.P
return
# def test_intro(self):
# """check PdfFit.intro()
# """
# return
def test_add_structure(self):
"""check PdfFit.add_structure()
"""
# skip test when diffpy.Structure is not installed
try:
from diffpy.Structure import Structure
except ImportError:
return
ni = Structure(filename=datafile('Ni.stru'))
self.P.add_structure(ni)
self.assertEqual(4, self.P.num_atoms())
return
# def test_read_struct(self):
# """check PdfFit.read_struct()
# """
# return
#
# def test_read_struct_string(self):
# """check PdfFit.read_struct_string()
# """
# return
#
# def test_read_data(self):
# """check PdfFit.read_data()
# """
# return
#
# def test_read_data_string(self):
# """check PdfFit.read_data_string()
# """
# return
#
# def test_read_data_lists(self):
# """check PdfFit.read_data_lists()
# """
# return
#
# def test_pdfrange(self):
# """check PdfFit.pdfrange()
# """
# return
#
# def test_reset(self):
# """check PdfFit.reset()
# """
# return
def test_alloc(self):
"""check PdfFit.alloc()
"""
# alloc and read_struct can be called in any order.
self.P.alloc('X', 25, 0.0, 0.01, 10, 1000)
# without a structure calculated PDF is all zero
self.P.calc()
Gzero = self.P.getpdf_fit()
self.assertEqual(1000*[0.0], Gzero)
self.P.read_struct(datafile('Ni.stru'))
self.P.calc()
# check r-values
r = self.P.getR()
self.assertEqual(1000, len(r))
for i in range(1000):
self.assertAlmostEqual(0.01*(i + 1), r[i], self.places)
Gfit_alloc_read = self.P.getpdf_fit()
# now try the other order
self.P.reset()
self.P.read_struct(datafile('Ni.stru'))
self.P.alloc('X', 25, 0.0, 0.01, 10, 1000)
self.P.calc()
Gfit_read_alloc = self.P.getpdf_fit()
# and they should be the same
self.assertEqual(Gfit_read_alloc, Gfit_alloc_read)
return
# def test_calc(self):
# """check PdfFit.calc()
# """
# return
#
# def test_refine(self):
# """check PdfFit.refine()
# """
#.........这里部分代码省略.........