Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
4f31b596
提交
4f31b596
authored
11月 29, 2020
作者:
Michael Osthege
提交者:
Brandon T. Willard
12月 04, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add theano.configparser hashing and context tests
上级
3e57181e
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
40 行增加
和
4 行删除
+40
-4
test_config.py
tests/test_config.py
+40
-4
没有找到文件。
tests/test_config.py
浏览文件 @
4f31b596
...
@@ -4,7 +4,7 @@ from unittest.mock import patch
...
@@ -4,7 +4,7 @@ from unittest.mock import patch
import
pytest
import
pytest
from
theano
import
configparser
from
theano
import
config
defaults
,
config
parser
from
theano.configdefaults
import
default_blas_ldflags
from
theano.configdefaults
import
default_blas_ldflags
from
theano.configparser
import
THEANO_FLAGS_DICT
,
AddConfigVar
,
ConfigParam
from
theano.configparser
import
THEANO_FLAGS_DICT
,
AddConfigVar
,
ConfigParam
...
@@ -85,6 +85,27 @@ def test_config_param_apply_and_validation():
...
@@ -85,6 +85,27 @@ def test_config_param_apply_and_validation():
cp
.
__set__
(
"cls"
,
"THEDEFAULT"
)
cp
.
__set__
(
"cls"
,
"THEDEFAULT"
)
def
test_config_hash
():
# TODO: use custom config instance for the test
root
=
configparser
.
config
configparser
.
AddConfigVar
(
"test_config_hash"
,
"A config var from a test case."
,
configparser
.
StrParam
(
"test_default"
),
root
=
root
,
)
h0
=
configparser
.
get_config_hash
()
with
configparser
.
change_flags
(
test_config_hash
=
"new_value"
):
assert
root
.
test_config_hash
==
"new_value"
h1
=
configparser
.
get_config_hash
()
h2
=
configparser
.
get_config_hash
()
assert
h1
!=
h0
assert
h2
==
h0
class
TestConfigTypes
:
class
TestConfigTypes
:
def
test_bool
(
self
):
def
test_bool
(
self
):
valids
=
{
valids
=
{
...
@@ -101,7 +122,6 @@ class TestConfigTypes:
...
@@ -101,7 +122,6 @@ class TestConfigTypes:
assert
param
.
validate
(
applied
)
is
not
False
assert
param
.
validate
(
applied
)
is
not
False
with
pytest
.
raises
(
ValueError
,
match
=
"Invalid value"
):
with
pytest
.
raises
(
ValueError
,
match
=
"Invalid value"
):
param
.
apply
(
"notabool"
)
param
.
apply
(
"notabool"
)
pass
def
test_enumstr
(
self
):
def
test_enumstr
(
self
):
cp
=
configparser
.
EnumStr
(
"blue"
,
[
"red"
,
"green"
,
"yellow"
])
cp
=
configparser
.
EnumStr
(
"blue"
,
[
"red"
,
"green"
,
"yellow"
])
...
@@ -110,7 +130,6 @@ class TestConfigTypes:
...
@@ -110,7 +130,6 @@ class TestConfigTypes:
cp
.
apply
(
"foo"
)
cp
.
apply
(
"foo"
)
with
pytest
.
raises
(
ValueError
,
match
=
"Non-str value"
):
with
pytest
.
raises
(
ValueError
,
match
=
"Non-str value"
):
configparser
.
EnumStr
(
default
=
"red"
,
options
=
[
"red"
,
12
,
"yellow"
])
configparser
.
EnumStr
(
default
=
"red"
,
options
=
[
"red"
,
12
,
"yellow"
])
pass
def
test_deviceparam
(
self
):
def
test_deviceparam
(
self
):
cp
=
configparser
.
DeviceParam
(
"cpu"
,
mutable
=
False
)
cp
=
configparser
.
DeviceParam
(
"cpu"
,
mutable
=
False
)
...
@@ -123,8 +142,25 @@ class TestConfigTypes:
...
@@ -123,8 +142,25 @@ class TestConfigTypes:
assert
str
(
cp
)
==
"None (cpu, opencl*, cuda*) "
assert
str
(
cp
)
==
"None (cpu, opencl*, cuda*) "
def
test_config_context
():
# TODO: use custom config instance for the test
root
=
configparser
.
config
configparser
.
AddConfigVar
(
"test_config_context"
,
"A config var from a test case."
,
configparser
.
StrParam
(
"test_default"
),
root
=
root
,
)
assert
hasattr
(
root
,
"test_config_context"
)
assert
root
.
test_config_context
==
"test_default"
with
configparser
.
change_flags
(
test_config_context
=
"new_value"
):
assert
root
.
test_config_context
==
"new_value"
assert
root
.
test_config_context
==
"test_default"
def
test_mode_apply
():
def
test_mode_apply
():
from
theano
import
configdefaults
assert
configdefaults
.
filter_mode
(
"DebugMode"
)
==
"DebugMode"
assert
configdefaults
.
filter_mode
(
"DebugMode"
)
==
"DebugMode"
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论