Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
flybirding10011
DI-treetensor
提交
84984ec1
D
DI-treetensor
项目概览
flybirding10011
/
DI-treetensor
与 Fork 源项目一致
Fork自
OpenDILab开源决策智能平台 / DI-treetensor
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DI-treetensor
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
84984ec1
编写于
9月 20, 2021
作者:
HansBug
😆
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test, doc(hansbug): split treetensor.common.Object out of the original position
上级
745b5b8e
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
104 addition
and
24 deletion
+104
-24
docs/source/api_doc/common/index.rst
docs/source/api_doc/common/index.rst
+3
-2
docs/source/api_doc/common/object.rst
docs/source/api_doc/common/object.rst
+11
-0
docs/source/api_doc/common/trees.rst
docs/source/api_doc/common/trees.rst
+17
-0
docs/source/api_doc/common/trees.rstc
docs/source/api_doc/common/trees.rstc
+0
-1
docs/source/api_doc/common/wrappers.rst
docs/source/api_doc/common/wrappers.rst
+22
-0
docs/source/api_doc/common/wrappers.rstc
docs/source/api_doc/common/wrappers.rstc
+0
-1
test/common/__init__.py
test/common/__init__.py
+1
-0
test/common/test_object.py
test/common/test_object.py
+16
-0
test/common/test_trees.py
test/common/test_trees.py
+2
-11
treetensor/common/__init__.py
treetensor/common/__init__.py
+1
-0
treetensor/common/object.py
treetensor/common/object.py
+30
-0
treetensor/common/trees.py
treetensor/common/trees.py
+1
-9
未找到文件。
docs/source/api_doc/common/index.rst
浏览文件 @
84984ec1
...
...
@@ -4,5 +4,6 @@ treetensor.common
.. toctree::
:maxdepth: 3
trees.auto
wrappers.auto
object
trees
wrappers
docs/source/api_doc/common/object.rst
0 → 100644
浏览文件 @
84984ec1
treetensor.common.object
===============================
.. currentmodule:: treetensor.common
Object
-----------------
.. autoclass:: Object
:members: __init__
docs/source/api_doc/common/trees.rst
0 → 100644
浏览文件 @
84984ec1
treetensor.common.trees
==============================
.. py:currentmodule:: treetensor.common.trees
print_tree
------------------
.. autofunction:: print_tree
BaseTreeStruct
-----------------------
.. autoclass:: BaseTreeStruct
:members:
docs/source/api_doc/common/trees.rstc
已删除
100644 → 0
浏览文件 @
745b5b8e
treetensor.common.trees
\ No newline at end of file
docs/source/api_doc/common/wrappers.rst
0 → 100644
浏览文件 @
84984ec1
treetensor.common.wrappers
===============================
.. py:currentmodule:: treetensor.common
kwreduce
-------------------
.. autofunction:: kwreduce
vreduce
-------------------
.. autofunction:: vreduce
ireduce
-------------------
.. autofunction:: ireduce
docs/source/api_doc/common/wrappers.rstc
已删除
100644 → 0
浏览文件 @
745b5b8e
treetensor.common.wrappers
\ No newline at end of file
test/common/__init__.py
浏览文件 @
84984ec1
from
.test_object
import
TestCommonObject
from
.test_trees
import
TestCommonTrees
test/common/test_object.py
0 → 100644
浏览文件 @
84984ec1
import
pytest
from
treevalue
import
typetrans
,
TreeValue
from
treetensor.common
import
Object
@
pytest
.
mark
.
unittest
class
TestCommonObject
:
def
test_object
(
self
):
t
=
Object
(
1
)
assert
isinstance
(
t
,
int
)
assert
t
==
1
assert
Object
({
'a'
:
1
,
'b'
:
2
})
==
typetrans
(
TreeValue
({
'a'
:
1
,
'b'
:
2
}),
Object
)
test/common/test_trees.py
浏览文件 @
84984ec1
...
...
@@ -2,9 +2,9 @@ import io
import
pytest
import
torch
from
treevalue
import
typetrans
,
TreeValue
,
general_tree_value
from
treevalue
import
general_tree_value
from
treetensor.common
import
Object
,
print_tree
from
treetensor.common
import
print_tree
def
text_compares
(
expected
,
actual
):
...
...
@@ -24,15 +24,6 @@ Expected: {e}
@
pytest
.
mark
.
unittest
class
TestCommonTrees
:
def
test_object
(
self
):
t
=
Object
(
1
)
assert
isinstance
(
t
,
int
)
assert
t
==
1
assert
Object
({
'a'
:
1
,
'b'
:
2
})
==
typetrans
(
TreeValue
({
'a'
:
1
,
'b'
:
2
}),
Object
)
def
test_print_tree
(
self
):
class
_TempTree
(
general_tree_value
()):
def
__repr__
(
self
):
...
...
treetensor/common/__init__.py
浏览文件 @
84984ec1
from
.object
import
*
from
.trees
import
*
from
.wrappers
import
*
treetensor/common/object.py
0 → 100644
浏览文件 @
84984ec1
from
.trees
import
BaseTreeStruct
,
clsmeta
__all__
=
[
"Object"
,
]
def
_object
(
obj
):
return
obj
class
Object
(
BaseTreeStruct
,
metaclass
=
clsmeta
(
_object
,
allow_dict
=
True
)):
def
__init__
(
self
,
data
):
"""
In :class:`treetensor.common.Object`, object or object tree can be initialized.
Examples::
>>> from treetensor.common import Object
>>> Object(1)
1
>>> Object({'a': 1, 'b': 2, 'x': {'c': 233}})
<Object 0x7fe00b1153a0>
├── a --> 1
├── b --> 2
└── x --> <Object 0x7fe00b115ee0>
└── c --> 233
"""
super
(
BaseTreeStruct
,
self
).
__init__
(
data
)
treetensor/common/trees.py
浏览文件 @
84984ec1
...
...
@@ -13,7 +13,7 @@ from treevalue.utils import post_process
from
..utils
import
replaceable_partial
,
args_mapping
__all__
=
[
'BaseTreeStruct'
,
"Object"
,
'BaseTreeStruct'
,
'print_tree'
,
'clsmeta'
,
]
...
...
@@ -118,11 +118,3 @@ def clsmeta(func, allow_dict: bool = False):
return
_result
return
_MetaClass
def
_object
(
obj
):
return
obj
class
Object
(
BaseTreeStruct
,
metaclass
=
clsmeta
(
_object
,
allow_dict
=
True
)):
pass
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录