Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
626104a8
提交
626104a8
authored
4月 15, 2015
作者:
Frédéric Bastien
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2744 from mohammadpz/pep8
Pep8
上级
d99cb9df
24a8dc48
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
31 行增加
和
33 行删除
+31
-33
configdefaults.py
theano/configdefaults.py
+0
-0
configparser.py
theano/configparser.py
+19
-18
gradient.py
theano/gradient.py
+0
-0
ifelse.py
theano/ifelse.py
+0
-0
test_flake8.py
theano/tests/test_flake8.py
+0
-5
updates.py
theano/updates.py
+12
-10
没有找到文件。
theano/configdefaults.py
浏览文件 @
626104a8
差异被折叠。
点击展开。
theano/configparser.py
浏览文件 @
626104a8
...
...
@@ -44,9 +44,9 @@ def parse_config_string(config_string, issue_warnings=True):
if
len
(
kv_tuple
)
==
1
:
if
issue_warnings
:
TheanoConfigWarning
.
warn
(
(
"Config key '
%
s' has no value, ignoring it"
%
kv_tuple
[
0
]),
stacklevel
=
1
)
(
"Config key '
%
s' has no value, ignoring it"
%
kv_tuple
[
0
]),
stacklevel
=
1
)
else
:
k
,
v
=
kv_tuple
# subsequent values for k will override earlier ones
...
...
@@ -77,7 +77,7 @@ theano_cfg = ConfigParser.SafeConfigParser(
'TEMP'
:
os
.
getenv
(
"TEMP"
,
""
),
'TMP'
:
os
.
getenv
(
"TMP"
,
""
),
'PID'
:
str
(
os
.
getpid
()),
}
}
)
theano_cfg
.
read
(
config_files
)
# Having a raw version of the config around as well enables us to pass
...
...
@@ -145,7 +145,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
.
cc
.
hash_from_code
(
'
\n
'
.
join
(
[
'
%
s =
%
s'
%
(
cv
.
fullname
,
cv
.
__get__
())
for
cv
in
all_opts
]))
[
'
%
s =
%
s'
%
(
cv
.
fullname
,
cv
.
__get__
())
for
cv
in
all_opts
]))
class
TheanoConfigParser
(
object
):
...
...
@@ -217,11 +217,11 @@ def AddConfigVar(name, doc, configparam, root=config, in_c_key=True):
_i_am_a_config_class
=
True
setattr
(
root
.
__class__
,
sections
[
0
],
SubObj
())
newroot
=
getattr
(
root
,
sections
[
0
])
if
(
not
getattr
(
newroot
,
'_i_am_a_config_class'
,
False
)
or
isinstance
(
newroot
,
type
)):
if
(
not
getattr
(
newroot
,
'_i_am_a_config_class'
,
False
)
or
isinstance
(
newroot
,
type
)):
raise
TypeError
(
'Internal config nodes must be config class instances'
,
newroot
)
'Internal config nodes must be config class instances'
,
newroot
)
return
AddConfigVar
(
'.'
.
join
(
sections
[
1
:]),
doc
,
configparam
,
root
=
newroot
,
in_c_key
=
in_c_key
)
else
:
...
...
@@ -235,7 +235,8 @@ def AddConfigVar(name, doc, configparam, root=config, in_c_key=True):
if
not
callable
(
configparam
.
default
):
configparam
.
__get__
()
else
:
# We do not want to evaluate now the default value when it is a callable.
# 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.
...
...
@@ -282,8 +283,8 @@ class ConfigParam(object):
def
__set__
(
self
,
cls
,
val
):
if
not
self
.
allow_override
and
hasattr
(
self
,
'val'
):
raise
Exception
(
"Can't change the value of this config parameter "
"after initialization!"
)
"Can't change the value of this config parameter "
"after initialization!"
)
# print "SETTING PARAM", self.fullname,(cls), val
if
self
.
filter
:
self
.
val
=
self
.
filter
(
val
)
...
...
@@ -300,7 +301,7 @@ class EnumStr(ConfigParam):
for
val
in
self
.
all
:
if
not
isinstance
(
val
,
basestring
):
raise
ValueError
(
'Valid values for an EnumStr parameter '
'should be strings'
,
val
,
type
(
val
))
'should be strings'
,
val
,
type
(
val
))
convert
=
kwargs
.
get
(
"convert"
,
None
)
...
...
@@ -332,13 +333,13 @@ class TypedParam(ConfigParam):
return
cast_val
else
:
raise
ValueError
(
'Invalid value (
%
s) for configuration variable '
'"
%
s".'
%
(
val
,
self
.
fullname
),
val
)
'Invalid value (
%
s) for configuration variable '
'"
%
s".'
%
(
val
,
self
.
fullname
),
val
)
return
cast_val
super
(
TypedParam
,
self
)
.
__init__
(
default
,
filter
,
allow_override
=
allow_override
)
allow_override
=
allow_override
)
def
__str__
(
self
):
return
'
%
s (
%
s) '
%
(
self
.
fullname
,
self
.
mytype
)
...
...
@@ -375,4 +376,4 @@ def BoolParam(default, is_valid=None, allow_override=True):
is_valid
=
is_valid_bool
return
TypedParam
(
default
,
booltype
,
is_valid
,
allow_override
=
allow_override
)
allow_override
=
allow_override
)
theano/gradient.py
浏览文件 @
626104a8
差异被折叠。
点击展开。
theano/ifelse.py
浏览文件 @
626104a8
差异被折叠。
点击展开。
theano/tests/test_flake8.py
浏览文件 @
626104a8
...
...
@@ -17,13 +17,8 @@ except ImportError:
flake8_available
=
False
whitelist_flake8
=
[
"updates.py"
,
"__init__.py"
,
"configparser.py"
,
"ifelse.py"
,
"version.py"
,
"configdefaults.py"
,
"gradient.py"
,
"compat/python2x.py"
,
"compat/six.py"
,
"compat/__init__.py"
,
...
...
theano/updates.py
浏览文件 @
626104a8
"""Defines Updates object for storing a (SharedVariable, new_value) mapping.
"""
from
theano.compat.python2x
import
OrderedDict
from
theano.compile.sharedvalue
import
SharedVariable
import
logging
import
warnings
__authors__
=
"theano-dev"
__copyright__
=
"(c) 2010, Universite de Montreal"
__license__
=
"3-clause BSD License"
...
...
@@ -8,12 +15,7 @@ __contact__ = "theano-dev <theano-dev@googlegroups.com>"
__docformat__
=
"restructuredtext en"
from
theano.compat.python2x
import
OrderedDict
from
theano.compile.sharedvalue
import
SharedVariable
import
logging
logger
=
logging
.
getLogger
(
'theano.updates'
)
import
warnings
# Must be an OrderedDict or updates will be applied in a non-deterministic
...
...
@@ -26,9 +28,9 @@ class OrderedUpdates(OrderedDict):
"""
def
__init__
(
self
,
*
key
,
**
kwargs
):
if
(
len
(
key
)
>=
1
and
isinstance
(
key
[
0
],
dict
)
and
len
(
key
[
0
])
>
1
and
not
isinstance
(
key
[
0
],
OrderedDict
)):
isinstance
(
key
[
0
],
dict
)
and
len
(
key
[
0
])
>
1
and
not
isinstance
(
key
[
0
],
OrderedDict
)):
# Warn when using as input a non-ordered dictionary.
warnings
.
warn
(
'Initializing an `OrderedUpdates` from a '
'non-ordered dictionary with 2+ elements could '
...
...
@@ -62,8 +64,8 @@ class OrderedUpdates(OrderedDict):
if
other
is
None
:
return
if
(
isinstance
(
other
,
dict
)
and
len
(
other
)
>
1
and
not
isinstance
(
other
,
OrderedDict
)):
len
(
other
)
>
1
and
not
isinstance
(
other
,
OrderedDict
)):
# Warn about non-determinism.
warnings
.
warn
(
'Updating an `OrderedUpdates` with a '
'non-ordered dictionary with 2+ elements could '
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论