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


Python GroupBond.isBenzene方法代码示例

本文整理汇总了Python中rmgpy.molecule.group.GroupBond.isBenzene方法的典型用法代码示例。如果您正苦于以下问题:Python GroupBond.isBenzene方法的具体用法?Python GroupBond.isBenzene怎么用?Python GroupBond.isBenzene使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rmgpy.molecule.group.GroupBond的用法示例。


在下文中一共展示了GroupBond.isBenzene方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestGroupBond

# 需要导入模块: from rmgpy.molecule.group import GroupBond [as 别名]
# 或者: from rmgpy.molecule.group.GroupBond import isBenzene [as 别名]
class TestGroupBond(unittest.TestCase):
    """
    Contains unit tests of the GroupBond class.
    """

    def setUp(self):
        """
        A method called before each unit test in this class.
        """
        self.bond = GroupBond(None, None, order=[2])
        self.orderList = [[1], [2], [3], [1.5], [1,2], [2,1], [2,3], [1,2,3]]
    
    def testGetOrderStr(self):
        """
        test the Bond.getOrderStr() method
        """
        bond = GroupBond(None,None,order = [1,2,3,1.5])
        self.assertEqual(bond.getOrderStr(),['S','D','T','B'])
        
    def testSetOrderStr(self):
        """
        test the Bond.setOrderStr() method
        """
        
        self.bond.setOrderStr(["B",'T'])
        self.assertEqual(set(self.bond.order), set([3,1.5]))
    
    def testGetOrderNum(self):
        """
        test the Bond.getOrderNum() method
        """
        self.assertEqual(self.bond.getOrderNum(),[2])
        
    def testSetOrderNum(self):
        """
        test the Bond.setOrderNum() method
        """
        
        self.bond.setOrderNum([3,1,2])
        self.assertEqual(self.bond.getOrderStr(),['T','S','D'])

    def testIsSingle(self):
        """
        test the Bond.isSingle() method
        """
        self.bond.setOrderNum([1])
        self.assertTrue(self.bond.isSingle())

        #test interaction with wildcards
        self.bond.setOrderNum([1, 2, 3 , 1.5])
        self.assertFalse(self.bond.isSingle(wildcards = False))
        self.assertTrue(self.bond.isSingle(wildcards = True))

    def testIsDouble(self):
        """
        test the Bond.isDouble() method
        """
        self.bond.setOrderNum([2])
        self.assertTrue(self.bond.isDouble())

        #test interaction with wildcards
        self.bond.setOrderNum([1, 2, 3 , 1.5])
        self.assertFalse(self.bond.isDouble(wildcards = False))
        self.assertTrue(self.bond.isDouble(wildcards = True))
    
    def testIsTriple(self):
        """
        test the Bond.isTriple() method
        """
        self.bond.setOrderNum([3])
        self.assertTrue(self.bond.isTriple())

        #test interaction with wildcards
        self.bond.setOrderNum([1, 2, 3 , 1.5])
        self.assertFalse(self.bond.isTriple(wildcards = False))
        self.assertTrue(self.bond.isTriple(wildcards = True))

    def testIsBenzene(self):
        """
        test the Bond.isBenzene() method
        """
        self.bond.setOrderNum([1.5])
        self.assertTrue(self.bond.isBenzene())

        #test interaction with wildcards
        self.bond.setOrderNum([1, 2, 3 , 1.5])
        self.assertFalse(self.bond.isBenzene(wildcards = False))
        self.assertTrue(self.bond.isBenzene(wildcards = True))

    def testApplyActionBreakBond(self):
        """
        Test the GroupBond.applyAction() method for a BREAK_BOND action.
        """
        action = ['BREAK_BOND', '*1', 1, '*2']
        for order0 in self.orderList:
            bond0 = GroupBond(None, None, order=order0)
            bond = bond0.copy()
            try:
                bond.applyAction(action)
                self.fail('GroupBond.applyAction() unexpectedly processed a BREAK_BOND action.')
#.........这里部分代码省略.........
开发者ID:connie,项目名称:RMG-Py,代码行数:103,代码来源:groupTest.py


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