本文整理汇总了Python中diffpy.Structure.Structure.append方法的典型用法代码示例。如果您正苦于以下问题:Python Structure.append方法的具体用法?Python Structure.append怎么用?Python Structure.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类diffpy.Structure.Structure
的用法示例。
在下文中一共展示了Structure.append方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: convertDiffpyStru
# 需要导入模块: from diffpy.Structure import Structure [as 别名]
# 或者: from diffpy.Structure.Structure import append [as 别名]
def convertDiffpyStru(self, mode='xyz'):
'''
convert self.xxx to diffpy
:param mode: 'xyz' or 'xyz_c',
'xyz': pass fractional xyz
'xyz_c': pass Cartesian xyz directly
'''
rv = Structure()
if mode == 'xyz':
rv.lattice.setLatPar(*self.lat)
aa = Atom()
for i in range(self.n):
rv.append(aa, copy=True)
rv.element = self.element
rv.occupancy = self.occ
rv.anisotropy = self.anisotropy
rv.U = self.uij_c
if mode == 'xyz':
rv.xyz = self.xyz
elif mode == 'xyz_c':
rv.xyz_cartn = self.xyz_c
rv.title = self.name
return self.addProp(rv)
示例2: TestStructure
# 需要导入模块: from diffpy.Structure import Structure [as 别名]
# 或者: from diffpy.Structure.Structure import append [as 别名]
#.........这里部分代码省略.........
self.assertListAlmostEqual(a0.xyz, 3*[0.0])
a1 = stru[1]
self.assertListAlmostEqual(a1.xyz, [2.0, 0.0, 2.0])
# def test_read(self):
# """check Structure.read()
# """
# return
#
# def test_readStr(self):
# """check Structure.readStr()
# """
# return
#
# def test_write(self):
# """check Structure.write()
# """
# return
#
# def test_writeStr(self):
# """check Structure.writeStr()
# """
# return
def test_aslist(self):
"""check Structure.tolist()
"""
lst = self.stru.tolist()
self.assertEqual(tuple(lst), tuple(self.stru))
self.assertEqual(list, type(lst))
return
def test_append(self):
"""check Structure.append()
"""
a = Atom("Si", (0.1, 0.2, 0.3))
lat = self.stru.lattice
self.stru.append(a)
alast = self.stru[-1]
self.assertEqual(3, len(self.stru))
self.assertEqual('Si', alast.element)
self.failUnless(lat is alast.lattice)
self.failUnless(numpy.array_equal(a.xyz, alast.xyz))
self.failIf(a is alast)
self.failIf(lat is a.lattice)
return
def test_insert(self):
"""check Structure.insert()
"""
a = Atom("Si", (0.1, 0.2, 0.3))
lat = self.stru.lattice
self.stru.insert(1, a)
a1 = self.stru[1]
self.assertEqual(3, len(self.stru))
self.assertEqual('Si', a1.element)
self.failUnless(lat is a1.lattice)
self.failUnless(numpy.array_equal(a.xyz, a1.xyz))
self.failIf(a is a1)
self.failIf(lat is a.lattice)
return
def test_extend(self):