提交 4fd45928 编写于 作者: Y Yu Yang

Merge remote-tracking branch 'qingqing/topology_fix' into feature/recommendation_v2_api

...@@ -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.
先完成此消息的编辑!
想要评论请 注册