Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
201b4610
提交
201b4610
authored
9月 29, 2015
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a way to determine if an option has the default value or not.
Also starts adressing issue #3468 a bit.
上级
55f671d3
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
10 行增加
和
6 行删除
+10
-6
configparser.py
theano/configparser.py
+10
-6
没有找到文件。
theano/configparser.py
浏览文件 @
201b4610
...
...
@@ -102,7 +102,7 @@ def change_flags(**kwargs):
l
=
[
v
for
v
in
theano
.
configparser
.
_config_var_list
if
v
.
fullname
==
k
]
assert
len
(
l
)
==
1
old_val
[
k
]
=
l
[
0
]
.
__get__
()
old_val
[
k
]
=
l
[
0
]
.
__get__
(
True
,
None
)
try
:
for
k
in
kwargs
:
l
=
[
v
for
v
in
theano
.
configparser
.
_config_var_list
...
...
@@ -167,7 +167,7 @@ def _config_print(thing, buf):
for
cv
in
_config_var_list
:
print
(
cv
,
file
=
buf
)
print
(
" Doc: "
,
cv
.
doc
,
file
=
buf
)
print
(
" Value: "
,
cv
.
__get__
(),
file
=
buf
)
print
(
" Value: "
,
cv
.
__get__
(
True
,
None
),
file
=
buf
)
print
(
""
,
file
=
buf
)
...
...
@@ -182,7 +182,7 @@ def get_config_md5():
all_opts
=
sorted
([
c
for
c
in
_config_var_list
if
c
.
in_c_key
],
key
=
lambda
cv
:
cv
.
fullname
)
return
theano
.
gof
.
utils
.
hash_from_code
(
'
\n
'
.
join
(
[
'
%
s =
%
s'
%
(
cv
.
fullname
,
cv
.
__get__
())
for
cv
in
all_opts
]))
[
'
%
s =
%
s'
%
(
cv
.
fullname
,
cv
.
__get__
(
True
,
None
))
for
cv
in
all_opts
]))
class
TheanoConfigParser
(
object
):
...
...
@@ -270,14 +270,14 @@ def AddConfigVar(name, doc, configparam, root=config, in_c_key=True):
# Trigger a read of the value from config files and env vars
# This allow to filter wrong value from the user.
if
not
callable
(
configparam
.
default
):
configparam
.
__get__
()
configparam
.
__get__
(
root
,
type
(
root
)
)
else
:
# We do not want to evaluate now the default value
# when it is a callable.
try
:
fetch_val_for_key
(
configparam
.
fullname
)
# The user provided a value, filter it now.
configparam
.
__get__
()
configparam
.
__get__
(
root
,
type
(
root
)
)
except
KeyError
:
pass
setattr
(
root
.
__class__
,
sections
[
0
],
configparam
)
...
...
@@ -294,6 +294,7 @@ class ConfigParam(object):
self
.
default
=
default
self
.
filter
=
filter
self
.
allow_override
=
allow_override
self
.
is_default
=
True
# N.B. --
# self.fullname # set by AddConfigVar
# self.doc # set by AddConfigVar
...
...
@@ -304,10 +305,13 @@ class ConfigParam(object):
# Calling `filter` here may actually be harmful if the default value is
# invalid and causes a crash or has unwanted side effects.
def
__get__
(
self
,
*
args
):
def
__get__
(
self
,
cls
,
type_
):
if
cls
is
None
:
return
self
if
not
hasattr
(
self
,
'val'
):
try
:
val_str
=
fetch_val_for_key
(
self
.
fullname
)
self
.
is_default
=
False
except
KeyError
:
if
callable
(
self
.
default
):
val_str
=
self
.
default
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论