本文整理汇总了Python中diffpy.Structure.Structure.insert方法的典型用法代码示例。如果您正苦于以下问题:Python Structure.insert方法的具体用法?Python Structure.insert怎么用?Python Structure.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类diffpy.Structure.Structure
的用法示例。
在下文中一共展示了Structure.insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestStructure
# 需要导入模块: from diffpy.Structure import Structure [as 别名]
# 或者: from diffpy.Structure.Structure import insert [as 别名]
#.........这里部分代码省略.........
# """
# 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):
"""check Structure.extend()
"""
stru = self.stru
cdse = Structure(filename=cdsefile)
lst = stru.tolist()
stru.extend(cdse)
self.assertEqual(6, len(stru))
self.failUnless(all([a.lattice is stru.lattice for a in stru]))
self.failUnless(stru.lattice is a.lattice)
self.assertEqual(lst, stru.tolist()[:2])
self.assertNotEqual(stru[-1], cdse[-1])
return
def test___getitem__(self):
"""check Structure.__getitem__()