Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDILab开源决策智能平台
treevalue
提交
2ad248f3
T
treevalue
项目概览
OpenDILab开源决策智能平台
/
treevalue
大约 1 年 前同步成功
通知
3
Star
213
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
treevalue
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2ad248f3
编写于
2月 22, 2022
作者:
HansBug
😆
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dev(hansbug): update the default value of include_nodes from False to True
上级
c803ab42
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
14 addition
and
4 deletion
+14
-4
test/tree/general/base.py
test/tree/general/base.py
+2
-2
test/tree/tree/test_service.py
test/tree/tree/test_service.py
+10
-0
treevalue/tree/general/general.py
treevalue/tree/general/general.py
+1
-1
treevalue/tree/tree/service.pyx
treevalue/tree/tree/service.pyx
+1
-1
未找到文件。
test/tree/general/base.py
浏览文件 @
2ad248f3
...
@@ -623,7 +623,7 @@ def get_tree_test(tree_value_clazz: Type[TreeValue]):
...
@@ -623,7 +623,7 @@ def get_tree_test(tree_value_clazz: Type[TreeValue]):
def
test_walk
(
self
):
def
test_walk
(
self
):
tv1
=
tree_value_clazz
({
'a'
:
1
,
'b'
:
'dks'
,
'c'
:
{
'x'
:
2
,
'y'
:
3
}})
tv1
=
tree_value_clazz
({
'a'
:
1
,
'b'
:
'dks'
,
'c'
:
{
'x'
:
2
,
'y'
:
3
}})
for
p
,
v
in
tv1
.
walk
():
for
p
,
v
in
tv1
.
walk
(
include_nodes
=
False
):
if
p
==
(
'a'
,):
if
p
==
(
'a'
,):
assert
v
==
1
assert
v
==
1
elif
p
==
(
'b'
,):
elif
p
==
(
'b'
,):
...
@@ -635,7 +635,7 @@ def get_tree_test(tree_value_clazz: Type[TreeValue]):
...
@@ -635,7 +635,7 @@ def get_tree_test(tree_value_clazz: Type[TreeValue]):
else
:
else
:
pytest
.
fail
(
'Should not reach here - %s is accessed.'
%
(
repr
(
p
),))
pytest
.
fail
(
'Should not reach here - %s is accessed.'
%
(
repr
(
p
),))
for
p
,
v
in
tv1
.
walk
(
include_nodes
=
True
):
for
p
,
v
in
tv1
.
walk
():
if
p
==
():
if
p
==
():
assert
v
==
tv1
assert
v
==
tv1
elif
p
==
(
'a'
,):
elif
p
==
(
'a'
,):
...
...
test/tree/tree/test_service.py
浏览文件 @
2ad248f3
...
@@ -105,9 +105,17 @@ class TestTreeTreeService:
...
@@ -105,9 +105,17 @@ class TestTreeTreeService:
tv1
=
MyTreeValue
({
'a'
:
1
,
'b'
:
2
,
'c'
:
{
'x'
:
2
,
'y'
:
3
}})
tv1
=
MyTreeValue
({
'a'
:
1
,
'b'
:
2
,
'c'
:
{
'x'
:
2
,
'y'
:
3
}})
assert
dict
(
walk
(
tv1
,
include_nodes
=
False
))
==
{
(
'a'
,):
1
,
(
'b'
,):
2
,
(
'c'
,
'x'
,):
2
,
(
'c'
,
'y'
,):
3
,
}
assert
dict
(
walk
(
tv1
))
==
{
assert
dict
(
walk
(
tv1
))
==
{
():
MyTreeValue
({
'a'
:
1
,
'b'
:
2
,
'c'
:
{
'x'
:
2
,
'y'
:
3
}}),
(
'a'
,):
1
,
(
'a'
,):
1
,
(
'b'
,):
2
,
(
'b'
,):
2
,
(
'c'
,):
MyTreeValue
({
'x'
:
2
,
'y'
:
3
}),
(
'c'
,
'x'
,):
2
,
(
'c'
,
'x'
,):
2
,
(
'c'
,
'y'
,):
3
,
(
'c'
,
'y'
,):
3
,
}
}
...
@@ -126,8 +134,10 @@ class TestTreeTreeService:
...
@@ -126,8 +134,10 @@ class TestTreeTreeService:
'c'
:
delayed
(
lambda
:
tv1
.
c
),
'c'
:
delayed
(
lambda
:
tv1
.
c
),
})
})
assert
dict
(
walk
(
tv2
))
==
{
assert
dict
(
walk
(
tv2
))
==
{
():
MyTreeValue
({
'a'
:
1
,
'b'
:
2
,
'c'
:
{
'x'
:
2
,
'y'
:
3
}}),
(
'a'
,):
1
,
(
'a'
,):
1
,
(
'b'
,):
2
,
(
'b'
,):
2
,
(
'c'
,):
MyTreeValue
({
'x'
:
2
,
'y'
:
3
}),
(
'c'
,
'x'
,):
2
,
(
'c'
,
'x'
,):
2
,
(
'c'
,
'y'
,):
3
,
(
'c'
,
'y'
,):
3
,
}
}
treevalue/tree/general/general.py
浏览文件 @
2ad248f3
...
@@ -210,7 +210,7 @@ def general_tree_value(base: Optional[Mapping[str, Any]] = None,
...
@@ -210,7 +210,7 @@ def general_tree_value(base: Optional[Mapping[str, Any]] = None,
return
filter_
(
self
,
func
,
remove_empty
)
return
filter_
(
self
,
func
,
remove_empty
)
@
_decorate_method
@
_decorate_method
def
walk
(
self
,
include_nodes
:
bool
=
Fals
e
):
def
walk
(
self
,
include_nodes
:
bool
=
Tru
e
):
"""
"""
Overview:
Overview:
Walk the values and nodes in the tree.
Walk the values and nodes in the tree.
...
...
treevalue/tree/tree/service.pyx
浏览文件 @
2ad248f3
...
@@ -106,7 +106,7 @@ def _p_walk(TreeStorage tree, object type_, tuple path, bool include_nodes):
...
@@ -106,7 +106,7 @@ def _p_walk(TreeStorage tree, object type_, tuple path, bool include_nodes):
yield
curpath
,
v
yield
curpath
,
v
@
cython
.
binding
(
True
)
@
cython
.
binding
(
True
)
cpdef
walk
(
TreeValue
tree
,
bool
include_nodes
=
Fals
e
):
cpdef
walk
(
TreeValue
tree
,
bool
include_nodes
=
Tru
e
):
"""
"""
Overview:
Overview:
Walk the values and nodes in the tree.
Walk the values and nodes in the tree.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录