提交 cda45793 编写于 作者: H hedaoyuan 提交者: GitHub

Merge pull request #1500 from qingqing01/topology_fix

Fix __bfs_travel__ in topology.py
...@@ -21,7 +21,21 @@ import layer as v2_layer ...@@ -21,7 +21,21 @@ import layer as v2_layer
__all__ = ['Topology'] __all__ = ['Topology']
def __flatten__(lis):
"""
Given a list, possibly nested to any level, return it flattened.
"""
new_lis = []
for item in lis:
if isinstance(item, collections.Sequence):
new_lis.extend(__flatten__(item))
else:
new_lis.append(item)
return new_lis
def __bfs_travel__(callback, *layers): def __bfs_travel__(callback, *layers):
layers = __flatten__(layers)
for each_layer in layers: for each_layer in layers:
__break__ = callback(each_layer) __break__ = callback(each_layer)
if __break__: if __break__:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册