Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
082d02f0
提交
082d02f0
authored
12月 07, 2020
作者:
Michael Osthege
提交者:
Brandon T. Willard
12月 09, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Pass instance when calling getter/setter
上级
755f385a
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
12 行增加
和
5 行删除
+12
-5
test_config.py
tests/test_config.py
+6
-0
configparser.py
theano/configparser.py
+6
-5
没有找到文件。
tests/test_config.py
浏览文件 @
082d02f0
...
@@ -103,6 +103,12 @@ def test_config_hash():
...
@@ -103,6 +103,12 @@ def test_config_hash():
assert
h2
==
h0
assert
h2
==
h0
def
test_config_print
():
root
=
configparser
.
config
result
=
str
(
root
)
assert
isinstance
(
result
,
str
)
class
TestConfigTypes
:
class
TestConfigTypes
:
def
test_bool
(
self
):
def
test_bool
(
self
):
valids
=
{
valids
=
{
...
...
theano/configparser.py
浏览文件 @
082d02f0
...
@@ -27,6 +27,7 @@ class _ChangeFlagsDecorator:
...
@@ -27,6 +27,7 @@ class _ChangeFlagsDecorator:
args
.
update
(
kwargs
)
args
.
update
(
kwargs
)
self
.
confs
=
{
k
:
_root
.
_config_var_dict
[
k
]
for
k
in
args
}
self
.
confs
=
{
k
:
_root
.
_config_var_dict
[
k
]
for
k
in
args
}
self
.
new_vals
=
args
self
.
new_vals
=
args
self
.
_root
=
_root
def
__call__
(
self
,
f
):
def
__call__
(
self
,
f
):
@wraps
(
f
)
@wraps
(
f
)
...
@@ -39,10 +40,10 @@ class _ChangeFlagsDecorator:
...
@@ -39,10 +40,10 @@ class _ChangeFlagsDecorator:
def
__enter__
(
self
):
def
__enter__
(
self
):
self
.
old_vals
=
{}
self
.
old_vals
=
{}
for
k
,
v
in
self
.
confs
.
items
():
for
k
,
v
in
self
.
confs
.
items
():
self
.
old_vals
[
k
]
=
v
.
__get__
(
True
,
None
)
self
.
old_vals
[
k
]
=
v
.
__get__
(
self
.
_root
,
self
.
_root
.
__class__
)
try
:
try
:
for
k
,
v
in
self
.
confs
.
items
():
for
k
,
v
in
self
.
confs
.
items
():
v
.
__set__
(
None
,
self
.
new_vals
[
k
])
v
.
__set__
(
self
.
_root
,
self
.
new_vals
[
k
])
except
Exception
:
except
Exception
:
_logger
.
error
(
f
"Failed to change flags for {self.confs}."
)
_logger
.
error
(
f
"Failed to change flags for {self.confs}."
)
self
.
__exit__
()
self
.
__exit__
()
...
@@ -50,7 +51,7 @@ class _ChangeFlagsDecorator:
...
@@ -50,7 +51,7 @@ class _ChangeFlagsDecorator:
def
__exit__
(
self
,
*
args
):
def
__exit__
(
self
,
*
args
):
for
k
,
v
in
self
.
confs
.
items
():
for
k
,
v
in
self
.
confs
.
items
():
v
.
__set__
(
None
,
self
.
old_vals
[
k
])
v
.
__set__
(
self
.
_root
,
self
.
old_vals
[
k
])
def
_hash_from_code
(
msg
):
def
_hash_from_code
(
msg
):
...
@@ -84,7 +85,7 @@ class TheanoConfigParser:
...
@@ -84,7 +85,7 @@ class TheanoConfigParser:
print
(
cv
,
file
=
buf
)
print
(
cv
,
file
=
buf
)
if
print_doc
:
if
print_doc
:
print
(
" Doc: "
,
cv
.
doc
,
file
=
buf
)
print
(
" Doc: "
,
cv
.
doc
,
file
=
buf
)
print
(
" Value: "
,
cv
.
__get__
(
True
,
None
),
file
=
buf
)
print
(
" Value: "
,
cv
.
__get__
(
self
,
self
.
__class__
),
file
=
buf
)
print
(
""
,
file
=
buf
)
print
(
""
,
file
=
buf
)
def
get_config_hash
(
self
):
def
get_config_hash
(
self
):
...
@@ -104,7 +105,7 @@ class TheanoConfigParser:
...
@@ -104,7 +105,7 @@ class TheanoConfigParser:
return
_hash_from_code
(
return
_hash_from_code
(
"
\n
"
.
join
(
"
\n
"
.
join
(
[
[
"{} = {}"
.
format
(
cv
.
fullname
,
cv
.
__get__
(
True
,
None
))
"{} = {}"
.
format
(
cv
.
fullname
,
cv
.
__get__
(
self
,
self
.
__class__
))
for
cv
in
all_opts
for
cv
in
all_opts
]
]
)
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论