Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDILab开源决策智能平台
treevalue
提交
e3219cd2
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,发现更多精彩内容 >>
提交
e3219cd2
编写于
8月 25, 2021
作者:
HansBug
😆
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
save the rise_demo_1.demo.py and rise_demo_2.demo.py
上级
3fef34d4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
12 addition
and
7 deletion
+12
-7
docs/source/tutorials/advanced_usage/rise_demo_1.demo.py
docs/source/tutorials/advanced_usage/rise_demo_1.demo.py
+1
-1
docs/source/tutorials/advanced_usage/rise_demo_2.demo.py
docs/source/tutorials/advanced_usage/rise_demo_2.demo.py
+11
-6
未找到文件。
docs/source/tutorials/advanced_usage/rise_demo_1.demo.py
浏览文件 @
e3219cd2
...
...
@@ -7,7 +7,7 @@ if __name__ == '__main__':
t3
=
TreeValue
({
'a'
:
6
,
'b'
:
0
,
'x'
:
{
'c'
:
-
5
,
'd'
:
17
}})
t4
=
TreeValue
({
'a'
:
0
,
'b'
:
-
17
,
'x'
:
{
'c'
:
-
8
,
'd'
:
15
}})
t5
=
TreeValue
({
'a'
:
3
,
'b'
:
9
,
'x'
:
{
'c'
:
11
,
'd'
:
-
17
}})
st
=
{
'first'
:
(
t1
,
t2
),
'second'
:
[
t3
,
{
'x'
:
t4
,
'y'
:
t5
}]
}
st
=
{
'first'
:
(
t1
,
t2
),
'second'
:
(
t3
,
{
'x'
:
t4
,
'y'
:
t5
})
}
tx
=
subside
(
st
)
# Rising process
...
...
docs/source/tutorials/advanced_usage/rise_demo_2.demo.py
浏览文件 @
e3219cd2
...
...
@@ -2,23 +2,28 @@ from treevalue import TreeValue, subside, rise
if
__name__
==
'__main__'
:
# The same demo as the subside docs
t1
=
TreeValue
({
'a'
:
1
,
'b'
:
2
,
'x'
:
{
'c'
:
3
,
'd'
:
4
}})
t2
=
TreeValue
({
'a'
:
-
14
,
'b'
:
9
,
'x'
:
{
'c'
:
3
,
'd'
:
8
}})
t11
=
TreeValue
({
'a'
:
1
,
'b'
:
2
,
'x'
:
{
'c'
:
3
,
'd'
:
4
}})
t12
=
TreeValue
({
'a'
:
3
,
'b'
:
9
,
'x'
:
{
'c'
:
15
,
'd'
:
41
}})
t21
=
TreeValue
({
'a'
:
-
14
,
'b'
:
9
,
'x'
:
{
'c'
:
3
,
'd'
:
8
}})
t22
=
TreeValue
({
'a'
:
-
31
,
'b'
:
82
,
'x'
:
{
'c'
:
47
,
'd'
:
32
}})
t3
=
TreeValue
({
'a'
:
6
,
'b'
:
0
,
'x'
:
{
'c'
:
-
5
,
'd'
:
17
}})
t4
=
TreeValue
({
'a'
:
0
,
'b'
:
-
17
,
'x'
:
{
'c'
:
-
8
,
'd'
:
15
}})
t5
=
TreeValue
({
'a'
:
3
,
'b'
:
9
,
'x'
:
{
'c'
:
11
,
'd'
:
-
17
}})
st
=
{
'first'
:
(
t1
,
t2
),
'second'
:
[
t3
,
{
'x'
:
t4
,
'y'
:
t5
}]
}
st
=
{
'first'
:
[(
t11
,
t21
),
(
t12
,
t22
)],
'second'
:
(
t3
,
{
'x'
:
t4
,
'y'
:
t5
})
}
tx
=
subside
(
st
)
# Rising process, with template
# only the top-leveled dict will be extracted,
# neither tuple, list nor low-leveled dict will not be extracted
# because they are not defined in `template` argument
st2
=
rise
(
tx
,
template
=
{
'first'
:
None
,
'second'
:
[
None
,
None
]
})
st2
=
rise
(
tx
,
template
=
{
'first'
:
[
None
],
'second'
:
(
None
,
None
)
})
print
(
'st2:'
,
st2
)
print
(
"st2['first']:"
)
print
(
st2
[
'first'
])
print
(
"st2['first'][0]:"
)
print
(
st2
[
'first'
][
0
])
print
(
"st2['first'][1]:"
)
print
(
st2
[
'first'
][
1
])
print
(
"st2['second'][0]:"
)
print
(
st2
[
'second'
][
0
])
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录