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


Python TreeDict.hash方法代码示例

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


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

示例1: testhashes_12

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import hash [as 别名]
 def testhashes_12(self):
     p1 = TreeDict('hashes_test_tree')
     p1.a.b.c.asdf = deepcopy(test_list)
     
     p2 = TreeDict('hashes_test_tree')
     p2.a.b.c.asdf = deepcopy(test_list)
     
     self.assert_(p1.hash() == p2.hash())
开发者ID:aurora1625,项目名称:treedict,代码行数:10,代码来源:test_hashes.py

示例2: testhashes_02

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import hash [as 别名]
    def testhashes_02(self):
        p1 = TreeDict('hashes_test_tree')
        p1.asdf = "1234"
        
        p2 = TreeDict('hashes_test_tree')
        p2.asdf = "1235"

        self.assert_(len(p1.hash()) != 0)
        self.assert_(p1.hash() != p2.hash())
开发者ID:aurora1625,项目名称:treedict,代码行数:11,代码来源:test_hashes.py

示例3: testhashes_03

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import hash [as 别名]
    def testhashes_03(self):
        p1 = TreeDict('hashes_test_tree')
        p1.asdf = "1234"
        
        p2 = TreeDict('hashes_test_tree')
        p2.asdf = "1234"

        self.assert_(len(p1.hash("asdf")) != 0)
        self.assert_(p1.hash("asdf") == p2.hash("asdf"))
开发者ID:aurora1625,项目名称:treedict,代码行数:11,代码来源:test_hashes.py

示例4: testhashes_04

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import hash [as 别名]
    def testhashes_04(self):
        p1 = TreeDict('hashes_test_tree')
        p1.asdf = 221.12345139
        
        p2 = TreeDict('hashes_test_tree')
        p2.asdf = 221.12345139

        self.assert_(len(p1.hash("asdf")) != 0)
        self.assert_(p1.hash("asdf") == p2.hash("asdf"))
开发者ID:aurora1625,项目名称:treedict,代码行数:11,代码来源:test_hashes.py

示例5: testhashes_15_attaching

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import hash [as 别名]
    def testhashes_15_attaching(self):
        p1 = TreeDict('root')
        p1.b1 = TreeDict('b1')

        h = p1.hash()

        p1.attach(copy = False, recursive = True)
        
        self.assert_(p1.hash() != h)
开发者ID:aurora1625,项目名称:treedict,代码行数:11,代码来源:test_hashes.py

示例6: testhashes_05

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import hash [as 别名]
    def testhashes_05(self):
        p1 = TreeDict('hashes_test_tree')
        p1.asdf = 1234498484884499393939999324322432
         
        p2 = TreeDict('hashes_test_tree')
        p2.asdf = 1234498484884499393939999324322432

        self.assert_(len(p1.hash("asdf")) != 0)
        self.assert_(p1.hash("asdf") == p2.hash("asdf"))
开发者ID:aurora1625,项目名称:treedict,代码行数:11,代码来源:test_hashes.py

示例7: __call__

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import hash [as 别名]
 def __call__(self, *args, **kwargs):
     # Use TreeDict to allow for mutable parameters / kwargs
     kw_t = TreeDict(**kwargs)
     arg_t = TreeDict(args = args)
     cache_key = ( kw_t.hash(), arg_t.hash())
     try:
         return self.cache[cache_key]
     except KeyError:
         self.cache[cache_key] = value = self.func(*args, **kwargs)
         return value
开发者ID:aurora1625,项目名称:treedict,代码行数:12,代码来源:docstringscraps.py

示例8: testHashError_03

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import hash [as 别名]
    def testHashError_03(self):

        p = TreeDict()

        p.a.b = {'a' : lambda: None}

        self.assertRaises(HashError, lambda: p.hash())

        try:
            p.hash()
        except HashError as he:
            self.assert_(he.key == 'a.b', he.key)
开发者ID:aurora1625,项目名称:treedict,代码行数:14,代码来源:test_hashes.py

示例9: testHashError_05_custom

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import hash [as 别名]
    def testHashError_05_custom(self):

        p = TreeDict()

        class HType:
            def __init__(self):
                self.h = 1

            def __treedict_hash__(self):
                self.h += 1
                return self.h

        p.a.b.c = HType()

        self.assert_(p.hash() != p.hash())
开发者ID:aurora1625,项目名称:treedict,代码行数:17,代码来源:test_hashes.py

示例10: itemHash

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import hash [as 别名]
    def itemHash(self, *items):
	"""
	Returns a hash of arbitrary items.  This is intended to be
	used for fine-grained control of dependencies on parameters;
	the resulting value can passed to :ref:`inCache`,
	:ref:`loadFromCache`, and :ref:`saveToCache`.  For example::

          key = self.itemHash(self.p.x1, self.p.x2)

          if self.inCache(key):
              return self.loadFromCache(key)
          else:
              # process, create obj

              self.saveToCache(key, obj)

        Note that most of this functionality is provided by specifying
        `items` as a tuple to the key argument of :ref:inCache,
        :ref:loadFromCache, or :ref:saveToCache.
        
	"""

	t = TreeDict()

	for n, it in enumerate(items):
	    t["b%d" % n] = it

	return t.hash()
开发者ID:aurora1625,项目名称:lazyrunner,代码行数:30,代码来源:pmodulebase.py

示例11: testCopying_01d

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import hash [as 别名]
    def testCopying_01d(self):
        p1 = TreeDict('root')
        p1.a = 123

        p2 = deepcopy(p1)

        self.assert_(p1 == p2)
        self.assert_(p1.hash() == p2.hash())
开发者ID:aurora1625,项目名称:treedict,代码行数:10,代码来源:test_copying.py

示例12: testCopying_02d_dangling

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import hash [as 别名]
    def testCopying_02d_dangling(self):
        p1 = TreeDict('root')
        p1.a

        p2 = deepcopy(p1)

        self.assert_(p1 == p2)
        self.assert_(p1.hash() == p2.hash())
开发者ID:aurora1625,项目名称:treedict,代码行数:10,代码来源:test_copying.py

示例13: testhashes_20a_infinite_recursion_raises_error

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import hash [as 别名]
    def testhashes_20a_infinite_recursion_raises_error(self):
        p = TreeDict()

        p.makeBranch("a")

        p.a.b.c = p.a

        self.assertRaises(RuntimeError, lambda: p.hash())
开发者ID:aurora1625,项目名称:treedict,代码行数:10,代码来源:test_hashes.py

示例14: testpruning_03

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import hash [as 别名]
    def testpruning_03(self):
        p = TreeDict('prunetest')
        p.a.b.c = 123
        h1 = p.hash()

        self.assert_('a.b.c' in p)

        del p.a.b.c

        self.assert_('a.b.c' not in p)

        h2 = p.hash()

        p.a.b.c = 123
        h3 = p.hash()

        self.assert_(h1 != h2)
        self.assert_(h1 == h3)
开发者ID:aurora1625,项目名称:treedict,代码行数:20,代码来源:test_deletion.py

示例15: testpruning_02

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import hash [as 别名]
    def testpruning_02(self):
        p = TreeDict('prunetest')
        p.a.b.c = 123
        h1 = p.hash()

        self.assert_('a.b.c' in p)

        p.pop('a.b.c', prune_empty=True)

        self.assert_('a.b' not in p)

        h2 = p.hash()

        p.a.b.c = 123
        h3 = p.hash()

        self.assert_(h1 != h2)
        self.assert_(h1 == h3)
开发者ID:aurora1625,项目名称:treedict,代码行数:20,代码来源:test_deletion.py


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