本文整理汇总了Python中spack.spec.Spec.preorder_traversal方法的典型用法代码示例。如果您正苦于以下问题:Python Spec.preorder_traversal方法的具体用法?Python Spec.preorder_traversal怎么用?Python Spec.preorder_traversal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spack.spec.Spec
的用法示例。
在下文中一共展示了Spec.preorder_traversal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_unique_path_traversal
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import preorder_traversal [as 别名]
def test_unique_path_traversal(self):
dag = Spec('mpileaks ^zmpi')
dag.normalize()
names = ['mpileaks', 'callpath', 'dyninst', 'libdwarf', 'libelf',
'libelf', 'zmpi', 'fake', 'zmpi', 'fake']
pairs = zip([0,1,2,3,4,3,2,3,1,2], names)
traversal = dag.preorder_traversal(cover='paths')
self.assertListEqual([x.name for x in traversal], names)
traversal = dag.preorder_traversal(cover='paths', depth=True)
self.assertListEqual([(x, y.name) for x,y in traversal], pairs)
示例2: test_normalize_with_virtual_spec
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import preorder_traversal [as 别名]
def test_normalize_with_virtual_spec(self):
dag = Spec('mpileaks',
Spec('callpath',
Spec('dyninst',
Spec('libdwarf',
Spec('libelf')),
Spec('libelf')),
Spec('mpi')),
Spec('mpi'))
dag.normalize()
# make sure nothing with the same name occurs twice
counts = {}
for spec in dag.preorder_traversal(keyfun=id):
if not spec.name in counts:
counts[spec.name] = 0
counts[spec.name] += 1
for name in counts:
self.assertEqual(counts[name], 1, "Count for %s was not 1!" % name)