Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
flybirding10011
DI-treetensor
提交
798d9183
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,发现更多精彩内容 >>
提交
798d9183
编写于
9月 13, 2021
作者:
HansBug
😆
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
doc(hansbug): update doc for numpy part
上级
e6afc90e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
39 addition
and
13 deletion
+39
-13
docs/source/conf.py
docs/source/conf.py
+2
-0
treetensor/numpy/funcs.py
treetensor/numpy/funcs.py
+23
-1
treetensor/torch/funcs.py
treetensor/torch/funcs.py
+11
-11
treetensor/utils/doc.py
treetensor/utils/doc.py
+3
-1
未找到文件。
docs/source/conf.py
浏览文件 @
798d9183
...
...
@@ -103,6 +103,8 @@ release = __VERSION__
extensions
=
[
'sphinx.ext.autodoc'
,
'sphinx.ext.doctest'
,
'sphinx.ext.coverage'
,
'sphinx.ext.autosummary'
,
'sphinx.ext.mathjax'
,
'sphinx.ext.ifconfig'
,
'sphinx.ext.viewcode'
,
...
...
treetensor/numpy/funcs.py
浏览文件 @
798d9183
import
builtins
from
typing
import
List
import
numpy
as
np
from
treevalue
import
func_treelize
as
original_func_treelize
from
.numpy
import
TreeNumpy
from
..common
import
ireduce
,
TreeObject
from
..utils
import
replaceable_partial
from
..utils
import
replaceable_partial
,
inherit_doc
__all__
=
[
'all'
,
'any'
,
'equal'
,
'array_equal'
,
]
def
_doc_stripper
(
src
,
_
,
lines
:
List
[
str
]):
_name
,
_version
=
src
.
__name__
,
np
.
__version__
_short_version
=
'.'
.
join
(
_version
.
split
(
'.'
)[:
2
])
return
[
f
'.. note::'
,
f
''
,
f
' This documentation is based on '
f
' `numpy.
{
_name
}
<https://numpy.org/doc/
{
_short_version
}
/reference/generated/numpy.
{
_name
}
.html>`_ '
f
' in `numpy v
{
_version
}
<https://numpy.org/doc/
{
_short_version
}
/>`_.'
,
f
' **Its arguments
\'
arrangements depend on the version of numpy you installed**.'
,
f
''
,
*
lines
,
]
func_treelize
=
replaceable_partial
(
original_func_treelize
,
return_type
=
TreeNumpy
)
docs
=
replaceable_partial
(
inherit_doc
,
stripper
=
_doc_stripper
)
@
docs
(
np
.
all
)
@
ireduce
(
builtins
.
all
)
@
func_treelize
(
return_type
=
TreeObject
)
def
all
(
a
,
*
args
,
**
kwargs
):
return
np
.
all
(
a
,
*
args
,
**
kwargs
)
@
docs
(
np
.
any
)
@
ireduce
(
builtins
.
any
)
@
func_treelize
()
def
any
(
a
,
*
args
,
**
kwargs
):
return
np
.
any
(
a
,
*
args
,
**
kwargs
)
@
docs
(
np
.
equal
)
@
func_treelize
()
def
equal
(
x1
,
x2
,
*
args
,
**
kwargs
):
return
np
.
equal
(
x1
,
x2
,
*
args
,
**
kwargs
)
@
docs
(
np
.
array_equal
)
@
func_treelize
()
def
array_equal
(
a1
,
a2
,
*
args
,
**
kwargs
):
return
np
.
array_equal
(
a1
,
a2
,
*
args
,
**
kwargs
)
treetensor/torch/funcs.py
浏览文件 @
798d9183
...
...
@@ -9,6 +9,17 @@ from .tensor import TreeTensor, tireduce
from
..common
import
TreeObject
,
ireduce
from
..utils
import
replaceable_partial
,
direct_doc
,
inherit_doc
__all__
=
[
'zeros'
,
'zeros_like'
,
'randn'
,
'randn_like'
,
'randint'
,
'randint_like'
,
'ones'
,
'ones_like'
,
'full'
,
'full_like'
,
'empty'
,
'empty_like'
,
'all'
,
'any'
,
'eq'
,
'equal'
,
]
def
_doc_stripper
(
src
,
_
,
lines
:
List
[
str
]):
_name
,
_version
=
src
.
__name__
,
torch
.
__version__
...
...
@@ -30,17 +41,6 @@ def _doc_stripper(src, _, lines: List[str]):
func_treelize
=
replaceable_partial
(
original_func_treelize
,
return_type
=
TreeTensor
)
docs
=
post_process
(
post_process
(
direct_doc
))(
replaceable_partial
(
inherit_doc
,
stripper
=
_doc_stripper
))
__all__
=
[
'zeros'
,
'zeros_like'
,
'randn'
,
'randn_like'
,
'randint'
,
'randint_like'
,
'ones'
,
'ones_like'
,
'full'
,
'full_like'
,
'empty'
,
'empty_like'
,
'all'
,
'any'
,
'eq'
,
'equal'
,
]
@
docs
(
torch
.
zeros
)
@
func_treelize
()
...
...
treetensor/utils/doc.py
浏览文件 @
798d9183
...
...
@@ -7,7 +7,9 @@ __all__ = [
def
_strip_lines
(
doc
:
Optional
[
str
]):
_lines
=
(
doc
or
''
).
strip
().
splitlines
()
_lines
=
(
doc
or
''
).
splitlines
()
_first_line_id
,
_
=
sorted
(
filter
(
lambda
t
:
t
[
1
].
strip
(),
enumerate
(
_lines
)))[
0
]
_lines
=
_lines
[
_first_line_id
:]
_exist_lines
=
list
(
filter
(
str
.
strip
,
_lines
))
if
not
_exist_lines
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录