本文整理汇总了Python中spack.spec.Spec.traverse方法的典型用法代码示例。如果您正苦于以下问题:Python Spec.traverse方法的具体用法?Python Spec.traverse怎么用?Python Spec.traverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spack.spec.Spec
的用法示例。
在下文中一共展示了Spec.traverse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_postorder_path_traversal
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import traverse [as 别名]
def test_postorder_path_traversal(self):
dag = Spec('mpileaks ^zmpi')
dag.normalize()
names = ['libelf', 'libdwarf', 'libelf', 'dyninst', 'fake', 'zmpi',
'callpath', 'fake', 'zmpi', 'mpileaks']
pairs = list(zip([4, 3, 3, 2, 3, 2, 1, 2, 1, 0], names))
traversal = dag.traverse(cover='paths', order='post')
assert [x.name for x in traversal] == names
traversal = dag.traverse(cover='paths', depth=True, order='post')
assert [(x, y.name) for x, y in traversal] == pairs
示例2: test_postorder_node_traversal
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import traverse [as 别名]
def test_postorder_node_traversal(self):
dag = Spec('mpileaks ^zmpi')
dag.normalize()
names = ['libelf', 'libdwarf', 'dyninst', 'fake', 'zmpi',
'callpath', 'mpileaks']
pairs = zip([4,3,2,3,2,1,0], names)
traversal = dag.traverse(order='post')
self.assertEqual([x.name for x in traversal], names)
traversal = dag.traverse(depth=True, order='post')
self.assertEqual([(x, y.name) for x,y in traversal], pairs)
示例3: test_preorder_node_traversal
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import traverse [as 别名]
def test_preorder_node_traversal(self):
dag = Spec('mpileaks ^zmpi')
dag.normalize()
names = ['mpileaks', 'callpath', 'dyninst', 'libdwarf', 'libelf',
'zmpi', 'fake']
pairs = zip([0, 1, 2, 3, 4, 2, 3], names)
traversal = dag.traverse()
assert [x.name for x in traversal] == names
traversal = dag.traverse(depth=True)
assert [(x, y.name) for x, y in traversal] == pairs
示例4: test_preorder_path_traversal
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import traverse [as 别名]
def test_preorder_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.traverse(cover='paths')
self.assertEqual([x.name for x in traversal], names)
traversal = dag.traverse(cover='paths', depth=True)
self.assertEqual([(x, y.name) for x,y in traversal], pairs)
示例5: test_preorder_edge_traversal
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import traverse [as 别名]
def test_preorder_edge_traversal(self):
dag = Spec('mpileaks ^zmpi')
dag.normalize()
names = ['mpileaks', 'callpath', 'dyninst', 'libdwarf', 'libelf',
'libelf', 'zmpi', 'fake', 'zmpi']
pairs = list(zip([0, 1, 2, 3, 4, 3, 2, 3, 1], names))
traversal = dag.traverse(cover='edges')
assert [x.name for x in traversal] == names
traversal = dag.traverse(cover='edges', depth=True)
assert [(x, y.name) for x, y in traversal] == pairs
示例6: test_copy_satisfies_transitive
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import traverse [as 别名]
def test_copy_satisfies_transitive(self):
spec = Spec('dttop')
spec.concretize()
copy = spec.copy()
for s in spec.traverse():
assert s.satisfies(copy[s.name])
assert copy[s.name].satisfies(s)
示例7: read_spec
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import traverse [as 别名]
def read_spec(self, path):
"""Read the contents of a file and parse them as a spec"""
with closing(open(path)) as spec_file:
# Specs from files are assumed normal and concrete
spec = Spec(spec_file.read().replace('\n', ''))
if all(spack.db.exists(s.name) for s in spec.traverse()):
copy = spec.copy()
# TODO: It takes a lot of time to normalize every spec on read.
# TODO: Storing graph info with spec files would fix this.
copy.normalize()
if copy.concrete:
return copy # These are specs spack still understands.
# If we get here, either the spec is no longer in spack, or
# something about its dependencies has changed. So we need to
# just assume the read spec is correct. We'll lose graph
# information if we do this, but this is just for best effort
# for commands like uninstall and find. Currently Spack
# doesn't do anything that needs the graph info after install.
# TODO: store specs with full connectivity information, so
# that we don't have to normalize or reconstruct based on
# changing dependencies in the Spack tree.
spec._normal = True
spec._concrete = True
return spec
示例8: test_deptype_traversal_run
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import traverse [as 别名]
def test_deptype_traversal_run(self):
dag = Spec('dttop')
dag.normalize()
names = ['dttop', 'dtrun1', 'dtrun3']
traversal = dag.traverse(deptype='run')
assert [x.name for x in traversal] == names
示例9: test_failing_build
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import traverse [as 别名]
def test_failing_build(mock_archive):
spec = Spec('failing-build').concretized()
for s in spec.traverse():
fake_fetchify(mock_archive.url, s.package)
pkg = spec.package
with pytest.raises(spack.build_environment.ChildError):
pkg.do_install()
示例10: test_deptype_traversal_with_builddeps
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import traverse [as 别名]
def test_deptype_traversal_with_builddeps(self):
dag = Spec('dttop')
dag.normalize()
names = ['dttop', 'dtbuild1', 'dtbuild2', 'dtlink2',
'dtlink1', 'dtlink3', 'dtlink4']
traversal = dag.traverse(deptype=('build', 'link'))
assert [x.name for x in traversal] == names
示例11: test_deptype_traversal_full
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import traverse [as 别名]
def test_deptype_traversal_full(self):
dag = Spec('dttop')
dag.normalize()
names = ['dttop', 'dtbuild1', 'dtbuild2', 'dtlink2', 'dtrun2',
'dtlink1', 'dtlink3', 'dtlink4', 'dtrun1', 'dtlink5',
'dtrun3', 'dtbuild3']
traversal = dag.traverse(deptype=spack.alldeps)
assert [x.name for x in traversal] == names
示例12: test_virtual_is_fully_expanded_for_callpath
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import traverse [as 别名]
def test_virtual_is_fully_expanded_for_callpath(self):
# force dependence on fake "zmpi" by asking for MPI 10.0
spec = Spec('callpath ^[email protected]')
assert 'mpi' in spec._dependencies
assert 'fake' not in spec
spec.concretize()
assert 'zmpi' in spec._dependencies
assert all('mpi' not in d._dependencies for d in spec.traverse())
assert 'zmpi' in spec
assert 'mpi' in spec
assert 'fake' in spec._dependencies['zmpi'].spec
示例13: test_store
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import traverse [as 别名]
def test_store(mock_archive):
spec = Spec('cmake-client').concretized()
for s in spec.traverse():
fake_fetchify(mock_archive.url, s.package)
pkg = spec.package
try:
pkg.do_install()
except Exception:
pkg.remove_prefix()
raise
示例14: test_virtual_is_fully_expanded_for_callpath
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import traverse [as 别名]
def test_virtual_is_fully_expanded_for_callpath(self):
# force dependence on fake "zmpi" by asking for MPI 10.0
spec = Spec('callpath ^[email protected]')
self.assertTrue('mpi' in spec.dependencies)
self.assertFalse('fake' in spec)
spec.concretize()
self.assertTrue('zmpi' in spec.dependencies)
self.assertTrue(all(not 'mpi' in d.dependencies for d in spec.traverse()))
self.assertTrue('zmpi' in spec)
self.assertTrue('mpi' in spec)
self.assertTrue('fake' in spec.dependencies['zmpi'])
示例15: test_copy_simple
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import traverse [as 别名]
def test_copy_simple(self):
orig = Spec('mpileaks')
copy = orig.copy()
check_links(copy)
assert orig == copy
assert orig.eq_dag(copy)
assert orig._normal == copy._normal
assert orig._concrete == copy._concrete
# ensure no shared nodes bt/w orig and copy.
orig_ids = set(id(s) for s in orig.traverse())
copy_ids = set(id(s) for s in copy.traverse())
assert not orig_ids.intersection(copy_ids)