Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDILab开源决策智能平台
treevalue
提交
826b8a12
T
treevalue
项目概览
OpenDILab开源决策智能平台
/
treevalue
8 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
826b8a12
编写于
3月 07, 2023
作者:
HansBug
😆
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dev(hansbug): fix this version
上级
4891ef3c
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
22 addition
and
12 deletion
+22
-12
pyproject.toml
pyproject.toml
+1
-1
test/entry/cli/test_graph.py
test/entry/cli/test_graph.py
+3
-8
test/tree/general/base.py
test/tree/general/base.py
+4
-0
test/tree/integration/test_jax.py
test/tree/integration/test_jax.py
+2
-2
test/tree/tree/base.py
test/tree/tree/base.py
+5
-1
test/tree/tree/test_graph.py
test/tree/tree/test_graph.py
+4
-0
test/utils/test_tree.py
test/utils/test_tree.py
+3
-0
未找到文件。
pyproject.toml
浏览文件 @
826b8a12
...
...
@@ -42,7 +42,7 @@ test-command = [
archs
=
[
"x86_64"
,
"aarch64"
]
# Build for x86_64 and arm64
skip
=
[
"pp* *musllinux*"
]
# dependencies do not build for musl
before-test
=
[
# Unittest for linux
"
apt-get
install -y graphviz"
,
"
yum
install -y graphviz"
,
"pip install -r {project}/requirements-test.txt"
,
]
test-command
=
[
...
...
test/entry/cli/test_graph.py
浏览文件 @
826b8a12
...
...
@@ -9,20 +9,13 @@ import pytest
from
click.testing
import
CliRunner
from
hbutils.testing
import
cmdv
,
OS
from
treevalue
import
FastTreeValue
,
dump
,
graphics
from
treevalue
import
FastTreeValue
,
dump
from
treevalue.entry.cli
import
treevalue_cli
t1
=
FastTreeValue
({
'a'
:
1
,
'b'
:
2
,
'x'
:
{
'c'
:
3
,
'd'
:
4
}})
t2
=
FastTreeValue
({
'a'
:
1
,
'b'
:
{
2
,
4
},
'x'
:
{
'c'
:
[
1
,
3
],
'd'
:
4
}})
t3
=
FastTreeValue
({
'a'
:
1
,
'b'
:
2
,
'x'
:
{
'c'
:
t2
.
b
,
'd'
:
t2
.
x
.
c
}})
g
=
graphics
(
(
t1
,
't1'
),
(
t2
,
't2'
),
(
t3
,
't3'
),
title
=
'This is title for g.'
,
cfg
=
dict
(
bgcolor
=
'#ffffff00'
),
dup_value
=
(
list
,),
)
@
pytest
.
mark
.
unittest
class
TestEntryCliGraph
:
...
...
@@ -43,6 +36,7 @@ class TestEntryCliGraph:
assert
os
.
path
.
exists
(
'test_graph.gv'
)
assert
os
.
path
.
getsize
(
'test_graph.gv'
)
<=
2500
@
unittest
.
skipUnless
(
cmdv
(
'dot'
),
'Dot installed only'
)
def
test_simple_code_graph_to_stdout
(
self
):
runner
=
CliRunner
()
with
runner
.
isolated_filesystem
():
...
...
@@ -198,6 +192,7 @@ class TestEntryCliGraph:
assert
'first title'
not
in
content
assert
'This is title for g.'
in
content
@
unittest
.
skipUnless
(
cmdv
(
'dot'
),
'Dot installed only'
)
def
test_cfg
(
self
):
runner
=
CliRunner
()
with
runner
.
isolated_filesystem
():
...
...
test/tree/general/base.py
浏览文件 @
826b8a12
import
unittest
from
functools
import
reduce
from
operator
import
__mul__
from
typing
import
Type
import
numpy
as
np
import
pytest
from
hbutils.testing
import
cmdv
from
treevalue.tree
import
func_treelize
,
TreeValue
,
raw
,
mapping
,
delayed
,
FastTreeValue
from
..tree.base
import
get_treevalue_test
...
...
@@ -606,6 +608,7 @@ def get_fasttreevalue_test(treevalue_class: Type[FastTreeValue]):
assert
t2
.
x
.
c
is
not
t
.
x
.
c
assert
t2
.
x
.
d
is
not
t
.
x
.
d
@
unittest
.
skipUnless
(
cmdv
(
'dot'
),
'Dot installed only'
)
def
test_graph
(
self
):
t
=
treevalue_class
({
'a'
:
[
4
,
3
,
2
,
1
],
...
...
@@ -619,6 +622,7 @@ def get_fasttreevalue_test(treevalue_class: Type[FastTreeValue]):
graph
=
t
.
graph
(
't'
)
assert
len
(
graph
.
source
)
<=
2290
@
unittest
.
skipUnless
(
cmdv
(
'dot'
),
'Dot installed only'
)
def
test_graphics
(
self
):
t
=
treevalue_class
({
'a'
:
[
4
,
3
,
2
,
1
],
...
...
test/tree/integration/test_jax.py
浏览文件 @
826b8a12
...
...
@@ -23,7 +23,7 @@ class TestTreeTreeIntegration:
'a'
:
np
.
random
.
randint
(
0
,
10
,
(
2
,
3
)),
'b'
:
{
'x'
:
np
.
asarray
(
233.0
),
'y'
:
np
.
random
.
randn
(
2
,
3
)
'y'
:
np
.
random
.
randn
(
2
,
3
)
+
1
,
}
})
r1
=
double
(
t1
)
...
...
@@ -40,7 +40,7 @@ class TestTreeTreeIntegration:
'a'
:
np
.
random
.
randint
(
0
,
10
,
(
2
,
3
)),
'b'
:
{
'x'
:
np
.
asarray
(
233.0
),
'y'
:
np
.
random
.
randn
(
2
,
3
)
'y'
:
np
.
random
.
randn
(
2
,
3
)
+
1
,
}
})
r2
=
double
(
t2
)
...
...
test/tree/tree/base.py
浏览文件 @
826b8a12
import
pickle
import
re
import
unittest
from
typing
import
Type
import
pytest
from
hbutils.testing
import
OS
from
hbutils.testing
import
OS
,
cmdv
from
test.tree.tree.test_constraint
import
GreaterThanConstraint
from
treevalue
import
raw
,
TreeValue
,
delayed
,
ValidationError
...
...
@@ -750,6 +751,7 @@ def get_treevalue_test(treevalue_class: Type[TreeValue]):
assert
newt1
==
t1
assert
newt1
.
constraint
==
t1
.
constraint
@
unittest
.
skipUnless
(
cmdv
(
'dot'
),
'Dot installed only'
)
def
test_repr_svg
(
self
):
t1
=
get_demo_constraint_tree
()
assert
hasattr
(
t1
,
'_repr_svg_'
)
...
...
@@ -758,6 +760,7 @@ def get_treevalue_test(treevalue_class: Type[TreeValue]):
assert
isinstance
(
_repr_svg_
,
str
)
assert
4500
<=
len
(
_repr_svg_
)
<=
4900
@
unittest
.
skipUnless
(
cmdv
(
'dot'
),
'Dot installed only'
)
def
test_repr_png
(
self
):
t1
=
get_demo_constraint_tree
()
assert
hasattr
(
t1
,
'_repr_png_'
)
...
...
@@ -769,6 +772,7 @@ def get_treevalue_test(treevalue_class: Type[TreeValue]):
else
:
assert
16050
<=
len
(
_repr_png_
)
<=
20500
@
unittest
.
skipUnless
(
cmdv
(
'dot'
),
'Dot installed only'
)
def
test_repr_jpeg
(
self
):
t1
=
get_demo_constraint_tree
()
assert
hasattr
(
t1
,
'_repr_jpeg_'
)
...
...
test/tree/tree/test_graph.py
浏览文件 @
826b8a12
import
unittest
import
numpy
as
np
import
pytest
from
hbutils.testing
import
cmdv
from
treevalue
import
FastTreeValue
,
graphics
...
...
@@ -10,6 +13,7 @@ class MyFastTreeValue(FastTreeValue):
@
pytest
.
mark
.
unittest
class
TestTreeTreeGraph
:
@
unittest
.
skipUnless
(
cmdv
(
'dot'
),
'Dot installed only'
)
def
test_graphics
(
self
):
t
=
MyFastTreeValue
({
'a'
:
[
4
,
3
,
2
,
1
],
...
...
test/utils/test_tree.py
浏览文件 @
826b8a12
import
unittest
from
shutil
import
which
from
unittest.mock
import
patch
import
pytest
from
hbutils.testing
import
cmdv
from
treevalue.utils
import
build_graph
...
...
@@ -20,6 +22,7 @@ def no_dot():
@
pytest
.
mark
.
unittest
class
TestUtilsTree
:
@
unittest
.
skipUnless
(
cmdv
(
'dot'
),
'Dot installed only'
)
def
test_build_graph
(
self
):
t
=
{
'a'
:
1
,
'b'
:
2
,
'x'
:
{
'c'
:
3
,
'd'
:
4
}}
g
=
build_graph
((
t
,
't'
),
graph_title
=
"Demo of build_graph."
)
...
...
HansBug
😆
@HansBug
mentioned in commit
12ddef79
·
3月 08, 2023
mentioned in commit
12ddef79
mentioned in commit 12ddef798333889bbb9ff1e871e3641c1be948d0
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录