• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python treedict.getTree函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中treedict.getTree函数的典型用法代码示例。如果您正苦于以下问题:Python getTree函数的具体用法?Python getTree怎么用?Python getTree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: testRecall_copying

    def testRecall_copying(self):
        p1 = getTree('rt_r01')
        p1.makeBranch('rt_b01')

        p1c = p1.rt_b01.copy()

        p2 = getTree('rt_b01')
        
        self.assert_(p1c is not p2)
开发者ID:real666maverick,项目名称:treedict,代码行数:9,代码来源:test_centralsystem.py


示例2: testRecall_01

    def testRecall_01(self):
        self.assert_(not treedict.treeExists('testtree'))

        p = treedict.getTree('testtree')

        self.assert_(treedict.treeExists('testtree'))

        p2 = treedict.getTree('testtree')
        
        self.assert_(p is p2)
开发者ID:real666maverick,项目名称:treedict,代码行数:10,代码来源:test_centralsystem.py


示例3: testRecall_01

    def testRecall_01(self):
        name = 'testtree-%d' % common._inheritance_level

        self.assert_(not treedict.treeExists(name))

        p = treedict.getTree(name)

        self.assert_(treedict.treeExists(name))

        p2 = treedict.getTree(name)
        
        self.assert_(p is p2)
开发者ID:hoytak,项目名称:treedict,代码行数:12,代码来源:test_centralsystem.py


示例4: testConstraint_21_global__branches_track_original_deep

    def testConstraint_21_global__branches_track_original_deep(self):
        n = 100
        tn = unique_name()
        bnl = [unique_name() for i in range(n)]
        p = getTree(tn)

        fullbn = '.'.join(bnl)

        p.makeBranch(fullbn)

        bl = [None]*n

        for i, bn in enumerate(bnl):
            bl[i] = (p if i == 0 else bl[i-1])[bn]

        treedict.addGlobalConstraint(fullbn + '.x', [1], "not 1")

        for i, b in enumerate(bnl[:-1]):

            def f():
                bl[i]['.'.join(bnl[i+1:]) + '.x'] = 2

            self.assertRaises(ValueError, f)

        for i, b in enumerate(bnl[:-1]):
            bl[i]['.'.join(bnl[i+1:]) + '.x'] = 1
开发者ID:real666maverick,项目名称:treedict,代码行数:26,代码来源:test_constraints.py


示例5: testConstraint_06_afterwards_2

    def testConstraint_06_afterwards_2(self):
        tn = unique_name()
        bn = unique_name()

        p = getTree(tn)
        p[bn] = "bork"  # passes
        
        treedict.addConstraint(unique_name(), bn,["bork", "bork1"])
开发者ID:real666maverick,项目名称:treedict,代码行数:8,代码来源:test_constraints.py


示例6: testConstraint_17_global_constraint_not_added_on_failure

    def testConstraint_17_global_constraint_not_added_on_failure(self):
        tn1 = unique_name()
        tn2 = unique_name()
        bn = unique_name()
        
        p1 = getTree(tn1)
        p1[bn] = 2

        p2 = getTree(tn2)

        def f():
            treedict.addGlobalConstraint(bn, [1], "not 1")
            
        self.assertRaises(ValueError, f)

        # Should be fine still, as the constraint should be backed out
        p2[bn] = 2
开发者ID:real666maverick,项目名称:treedict,代码行数:17,代码来源:test_constraints.py


示例7: testConstraint_07_afterwards_global_2

    def testConstraint_07_afterwards_global_2(self):
        tn = unique_name()
        bn = unique_name()

        p = getTree(tn)
        p[bn] = "bork"
        
        treedict.addGlobalConstraint(bn, ["bork", "bork1"])
开发者ID:real666maverick,项目名称:treedict,代码行数:8,代码来源:test_constraints.py


示例8: testConstraint_09_branches_in_tree_names_02

    def testConstraint_09_branches_in_tree_names_02(self):
        tn = unique_name()

        p = getTree(tn)

        treedict.addConstraint(tn + '.b', 'a', [1], "not 1")

        # shouldn't throw
        p.b.a = 2
开发者ID:real666maverick,项目名称:treedict,代码行数:9,代码来源:test_constraints.py


示例9: testConstraint_09_branches_in_tree_names_03_control

    def testConstraint_09_branches_in_tree_names_03_control(self):
        tn = unique_name()
        tnb = tn + '.b'
        p = getTree(tnb)

        treedict.addConstraint(tnb, 'a', [1], "not 1")

        # shouldn't throw
        p.a = 1
开发者ID:real666maverick,项目名称:treedict,代码行数:9,代码来源:test_constraints.py


示例10: testConstraint_11_copying_02_aferwards

    def testConstraint_11_copying_02_aferwards(self):
        tn, bn = unique_name(), unique_name()

        p1 = getTree(tn)
        p1c = p1.makeBranch(bn).copy()
        p2 = getTree(bn)
        
        
        # Should work fine; not part of p2's family
        p1c.a = 2
        self.assert_(p1c.branchName() == bn)
        
        # Should cause throw, cause it's part of p2's family
        p2.a = 2
        
        def f(): treedict.addConstraint(bn, 'a', [1], "not 1")

        self.assertRaises(ValueError, f)
开发者ID:real666maverick,项目名称:treedict,代码行数:18,代码来源:test_constraints.py


示例11: testConstraint_25_Links_01

    def testConstraint_25_Links_01(self):
        tn = unique_name()
        p = treedict.getTree(tn)
        treedict.addConstraint(tn, 'a.b.link.v', [1], "not 1")

        p.d.v = 1
        p.a.b.link = p.d

        self.assert_(p.a.b.link.v == 1)
开发者ID:real666maverick,项目名称:treedict,代码行数:9,代码来源:test_constraints.py


示例12: testConstraint_07_afterwards_global_1_copy_control

    def testConstraint_07_afterwards_global_1_copy_control(self):
        tn = unique_name()
        bn = unique_name()

        p = getTree(tn)
        b = p.copy()
        b[bn] = 1
        
        # Should be fine
        treedict.addGlobalConstraint(bn, [1], "not 1")
开发者ID:real666maverick,项目名称:treedict,代码行数:10,代码来源:test_constraints.py


示例13: testConstraint_08_global_branch_copy_afterwards_1_control

    def testConstraint_08_global_branch_copy_afterwards_1_control(self):
        bn = unique_name()

        p = getTree(unique_name())
        p.makeBranch(bn).makeBranch('a')

        q = p[bn].copy()
        q.a.b = "bork"  # should be bad

        treedict.addGlobalConstraint(bn + '.a.b', ["bork"])
开发者ID:real666maverick,项目名称:treedict,代码行数:10,代码来源:test_constraints.py


示例14: testConstraint_06_afterwards_2_copy

    def testConstraint_06_afterwards_2_copy(self):
        tn = unique_name()
        bn = unique_name()

        p = getTree(tn)
        p[bn] = "bork"  # passes
        q = p.copy(deep = True)
        q[bn] = "bork1"  # passes

        treedict.addConstraint(tn, bn, ["bork", "bork1"])
开发者ID:real666maverick,项目名称:treedict,代码行数:10,代码来源:test_constraints.py


示例15: testSetGet06

    def testSetGet06(self):

        # regression test
        p = getTree('upt_08_bcg1_')
        p.a18462.a1732643.x = 1
        q = p.a18462.copy()
        q.a1732643.a1232 = "borkbork"  # should be bad

        self.assert_(p.a18462.a1732643.x == 1)
        self.assert_(q.a1732643.a1232 == "borkbork")
        self.assert_(q.a1732643.x == 1)
开发者ID:aurora1625,项目名称:treedict,代码行数:11,代码来源:test_setting.py


示例16: testConstraint_07_afterwards_global_1

    def testConstraint_07_afterwards_global_1(self):
        tn = unique_name()
        bn = unique_name()

        p = getTree(tn)
        p[bn] = "borkbork"
        
        def f():
            treedict.addGlobalConstraint(bn, ["bork", "bork1"])

        self.assertRaises(ValueError, f)
开发者ID:real666maverick,项目名称:treedict,代码行数:11,代码来源:test_constraints.py


示例17: testConstraint_17_constraint_not_added_on_failure__control

    def testConstraint_17_constraint_not_added_on_failure__control(self):
        tn1 = unique_name()
        tn2 = unique_name()
        bn = unique_name()
        
        p1 = getTree(tn1)
        p1[bn] = 1

        p2 = getTree(tn2)

        treedict.addGlobalConstraint(bn, [1], "not 1")
            
        # Should throw, as the constraint succeeded
        def f():
            p2[bn] = 2

        self.assertRaises(ValueError, f)

        # Control, should pass
        p2[bn] = 1
开发者ID:real666maverick,项目名称:treedict,代码行数:20,代码来源:test_constraints.py


示例18: testConstraint_27_after_Links_02_bad_value

    def testConstraint_27_after_Links_02_bad_value(self):
        tn = unique_name()
        p = treedict.getTree(tn)
        
        p.a.b.link = p.d
        p.d.v = 2

        def f():
            treedict.addConstraint(tn, 'a.b.link.v', [1], "not 1")
        
        self.assertRaises(ValueError, f)
开发者ID:real666maverick,项目名称:treedict,代码行数:11,代码来源:test_constraints.py


示例19: testConstraint_25_Links_03_set_in_linked_root

    def testConstraint_25_Links_03_set_in_linked_root(self):
        tn = unique_name()
        p = treedict.getTree(tn)
        treedict.addConstraint(tn, 'a.b.link.v', [1], "not 1")

        p.a.b.link = p.d

        def f():
            p.d.v = 1

        self.assertRaises(ValueError, f)
开发者ID:real666maverick,项目名称:treedict,代码行数:11,代码来源:test_constraints.py


示例20: testCopying_05b_central_system

    def testCopying_05b_central_system(self):
        # This test constrains the central system to have the same
        # name system as regular trees (I was tempted to do it
        # otherwise to make the constraints of copied branches
        # easier.)

        p = getTree('tc_root')
        b = p.makeBranch('b').copy()
    
        self.assert_(b.branchName(add_tree_name = True) == 'b', b.branchName(add_tree_name = True))
        self.assert_(p.b.branchName(add_path = True, add_tree_name = True) == 'tc_root.b',
                     p.b.branchName(add_path = True, add_tree_name = True))
开发者ID:hoytak,项目名称:treedict,代码行数:12,代码来源:test_copying.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python treedict.TreeDict类代码示例发布时间:2022-05-27
下一篇:
Python nodes.check_serialization函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap