Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDILab开源决策智能平台
treevalue
提交
bd4d17f5
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,发现更多精彩内容 >>
未验证
提交
bd4d17f5
编写于
7月 06, 2022
作者:
HansBug
😆
提交者:
GitHub
7月 06, 2022
1
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #53 from opendilab/dev/mutablemapping
dev(hansbug): add clear method into TreeValue
上级
a144b910
2e3c930d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
32 addition
and
1 deletion
+32
-1
docs/source/api_doc/tree/tree.rst
docs/source/api_doc/tree/tree.rst
+1
-1
test/tree/common/test_storage.py
test/tree/common/test_storage.py
+13
-0
test/tree/tree/test_tree.py
test/tree/tree/test_tree.py
+5
-0
treevalue/tree/common/storage.pxd
treevalue/tree/common/storage.pxd
+1
-0
treevalue/tree/common/storage.pyx
treevalue/tree/common/storage.pyx
+3
-0
treevalue/tree/tree/tree.pxd
treevalue/tree/tree/tree.pxd
+1
-0
treevalue/tree/tree/tree.pyx
treevalue/tree/tree/tree.pyx
+8
-0
未找到文件。
docs/source/api_doc/tree/tree.rst
浏览文件 @
bd4d17f5
...
...
@@ -9,7 +9,7 @@ TreeValue
---------------
.. autoclass:: TreeValue
:members: __init__, __getattribute__, __setattr__, __delattr__, __contains__, __repr__, __iter__, __hash__, __eq__, _attr_extern, __len__, __bool__, __str__, __getstate__, __setstate__, get, pop, keys, values, items, __getitem__, __setitem__, __delitem__, _getitem_extern, _setitem_extern, _delitem_extern, popitem
:members: __init__, __getattribute__, __setattr__, __delattr__, __contains__, __repr__, __iter__, __hash__, __eq__, _attr_extern, __len__, __bool__, __str__, __getstate__, __setstate__, get, pop, keys, values, items, __getitem__, __setitem__, __delitem__, _getitem_extern, _setitem_extern, _delitem_extern, popitem
, clear
.. _apidoc_tree_tree_delayed:
...
...
test/tree/common/test_storage.py
浏览文件 @
bd4d17f5
...
...
@@ -273,6 +273,19 @@ class TestTreeStorage:
with
pytest
.
raises
(
KeyError
):
t
.
del_
(
'fff'
)
def
test_clear
(
self
):
t
=
create_storage
({
'a'
:
1
,
'b'
:
2
,
'c'
:
raw
({
'x'
:
3
,
'y'
:
4
}),
'd'
:
{
'x'
:
3
,
'y'
:
4
}})
t
.
clear
()
assert
t
==
create_storage
({})
assert
t
.
size
()
==
0
d1
=
delayed_partial
(
lambda
:
1
)
d2
=
delayed_partial
(
lambda
x
:
x
+
1
,
d1
)
t1
=
create_storage
({
'a'
:
d1
,
'b'
:
d2
,
'c'
:
d1
,
'd'
:
100
})
t1
.
clear
()
assert
t1
==
create_storage
({})
assert
t1
.
size
()
==
0
def
test_contains
(
self
):
t
=
create_storage
({
'a'
:
1
,
'b'
:
2
,
'c'
:
raw
({
'x'
:
3
,
'y'
:
4
}),
'd'
:
{
'x'
:
3
,
'y'
:
4
}})
assert
t
.
contains
(
'a'
)
...
...
test/tree/tree/test_tree.py
浏览文件 @
bd4d17f5
...
...
@@ -355,6 +355,11 @@ class TestTreeTreeTree:
with
pytest
.
raises
(
KeyError
):
tv2
.
popitem
()
def
test_clear
(
self
):
tv1
=
TreeValue
({
'a'
:
1
,
'b'
:
2
,
'c'
:
{
'x'
:
2
,
'y'
:
3
},
'd'
:
raw
({
'x'
:
2
,
'y'
:
3
})})
assert
tv1
.
clear
()
is
None
assert
not
tv1
def
test_keys
(
self
):
tv1
=
TreeValue
({
'a'
:
1
,
'b'
:
2
,
'c'
:
{
'x'
:
2
,
'y'
:
3
},
'd'
:
raw
({
'x'
:
2
,
'y'
:
3
})})
assert
len
(
tv1
.
keys
())
==
4
...
...
treevalue/tree/common/storage.pxd
浏览文件 @
bd4d17f5
...
...
@@ -16,6 +16,7 @@ cdef class TreeStorage:
cpdef
public
object
pop_or_default
(
self
,
str
key
,
object
default
)
cpdef
public
tuple
popitem
(
self
)
cpdef
public
void
del_
(
self
,
str
key
)
except
*
cpdef
public
void
clear
(
self
)
cpdef
public
boolean
contains
(
self
,
str
key
)
cpdef
public
uint
size
(
self
)
cpdef
public
boolean
empty
(
self
)
...
...
treevalue/tree/common/storage.pyx
浏览文件 @
bd4d17f5
...
...
@@ -67,6 +67,9 @@ cdef class TreeStorage:
except
KeyError
:
raise
KeyError
(
f
"Key
{
repr
(
key
)
}
not found in this tree."
)
cpdef
public
void
clear
(
self
):
self
.
map
.
clear
()
cpdef
public
boolean
contains
(
self
,
str
key
):
return
key
in
self
.
map
...
...
treevalue/tree/tree/tree.pxd
浏览文件 @
bd4d17f5
...
...
@@ -23,6 +23,7 @@ cdef class TreeValue:
cpdef
get
(
self
,
str
key
,
object
default
=
*
)
cpdef
pop
(
self
,
str
key
,
object
default
=
*
)
cpdef
popitem
(
self
)
cpdef
void
clear
(
self
)
cpdef
treevalue_keys
keys
(
self
)
cpdef
treevalue_values
values
(
self
)
...
...
treevalue/tree/tree/tree.pyx
浏览文件 @
bd4d17f5
...
...
@@ -161,6 +161,14 @@ cdef class TreeValue:
except
KeyError
:
raise
KeyError
(
f
'popitem():
{
self
.
_type
.
__name__
}
is empty.'
)
@
cython
.
binding
(
True
)
cpdef
void
clear
(
self
):
"""
Overview:
Clear all the items in this treevalue object.
"""
self
.
_st
.
clear
()
@
cython
.
binding
(
True
)
cpdef
_attr_extern
(
self
,
str
key
):
r
"""
...
...
HansBug
😆
@HansBug
mentioned in commit
f392a71c
·
7月 14, 2022
mentioned in commit
f392a71c
mentioned in commit f392a71c55a2336a335445b94a32ab9701fd53d3
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录