当前位置: 首页>>代码示例>>Python>>正文


Python Structure.append方法代码示例

本文整理汇总了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)
开发者ID:XiaohaoYang,项目名称:srfitext,代码行数:28,代码来源:structure.py

示例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):
开发者ID:benfrandsen,项目名称:diffpy.Structure,代码行数:70,代码来源:TestStructure.py


注:本文中的diffpy.Structure.Structure.append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。