Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
3ff31f1a
Unverified
提交
3ff31f1a
authored
3月 20, 2018
作者:
abergeron
提交者:
GitHub
3月 20, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6583 from nouiz/flake8_version
Support more recent flake8 version
上级
546067df
f8678420
显示空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
38 行增加
和
20 行删除
+38
-20
setup.py
setup.py
+1
-1
__init__.py
theano/compat/__init__.py
+1
-1
configparser.py
theano/configparser.py
+1
-1
vm.py
theano/gof/vm.py
+4
-4
scan_opt.py
theano/scan_module/scan_opt.py
+1
-1
basic.py
theano/tensor/basic.py
+1
-1
breakpoint.py
theano/tests/breakpoint.py
+1
-1
test_flake8.py
theano/tests/test_flake8.py
+20
-2
test_gradient.py
theano/tests/test_gradient.py
+8
-8
没有找到文件。
setup.py
浏览文件 @
3ff31f1a
...
@@ -101,7 +101,7 @@ def do_setup():
...
@@ -101,7 +101,7 @@ def do_setup():
install_requires
=
[
'numpy>=1.9.1'
,
'scipy>=0.14'
,
'six>=1.9.0'
],
install_requires
=
[
'numpy>=1.9.1'
,
'scipy>=0.14'
,
'six>=1.9.0'
],
# pygments is a dependency for Sphinx code highlight
# pygments is a dependency for Sphinx code highlight
extras_require
=
{
extras_require
=
{
'test'
:
[
'nose>=1.3.0'
,
'parameterized'
,
'flake8
<3
'
],
'test'
:
[
'nose>=1.3.0'
,
'parameterized'
,
'flake8'
],
'doc'
:
[
'Sphinx>=0.5.1'
,
'pygments'
]
'doc'
:
[
'Sphinx>=0.5.1'
,
'pygments'
]
},
},
package_data
=
{
package_data
=
{
...
...
theano/compat/__init__.py
浏览文件 @
3ff31f1a
...
@@ -130,7 +130,7 @@ def maybe_add_to_os_environ_pathlist(var, newpath):
...
@@ -130,7 +130,7 @@ def maybe_add_to_os_environ_pathlist(var, newpath):
if
newpath
not
in
oldpaths
:
if
newpath
not
in
oldpaths
:
newpaths
=
os
.
pathsep
.
join
([
newpath
]
+
oldpaths
)
newpaths
=
os
.
pathsep
.
join
([
newpath
]
+
oldpaths
)
os
.
environ
[
var
]
=
newpaths
os
.
environ
[
var
]
=
newpaths
except
:
except
Exception
:
pass
pass
__all__
+=
[
'maybe_add_to_os_environ_pathlist'
]
__all__
+=
[
'maybe_add_to_os_environ_pathlist'
]
theano/configparser.py
浏览文件 @
3ff31f1a
...
@@ -124,7 +124,7 @@ class change_flags(object):
...
@@ -124,7 +124,7 @@ class change_flags(object):
try
:
try
:
for
k
,
v
in
iteritems
(
self
.
confs
):
for
k
,
v
in
iteritems
(
self
.
confs
):
v
.
__set__
(
None
,
self
.
new_vals
[
k
])
v
.
__set__
(
None
,
self
.
new_vals
[
k
])
except
:
except
Exception
:
self
.
__exit__
()
self
.
__exit__
()
raise
raise
...
...
theano/gof/vm.py
浏览文件 @
3ff31f1a
...
@@ -245,7 +245,7 @@ class Loop(VM):
...
@@ -245,7 +245,7 @@ class Loop(VM):
t1
=
time
.
time
()
t1
=
time
.
time
()
self
.
call_counts
[
i
]
+=
1
self
.
call_counts
[
i
]
+=
1
self
.
call_times
[
i
]
+=
t1
-
t0
self
.
call_times
[
i
]
+=
t1
-
t0
except
:
except
Exception
:
link
.
raise_with_op
(
node
,
thunk
)
link
.
raise_with_op
(
node
,
thunk
)
else
:
else
:
for
cont
in
self
.
pre_call_clear
:
for
cont
in
self
.
pre_call_clear
:
...
@@ -253,7 +253,7 @@ class Loop(VM):
...
@@ -253,7 +253,7 @@ class Loop(VM):
try
:
try
:
for
thunk
,
node
in
zip
(
self
.
thunks
,
self
.
nodes
):
for
thunk
,
node
in
zip
(
self
.
thunks
,
self
.
nodes
):
thunk
()
thunk
()
except
:
except
Exception
:
link
.
raise_with_op
(
node
,
thunk
)
link
.
raise_with_op
(
node
,
thunk
)
...
@@ -289,7 +289,7 @@ class LoopGC(VM):
...
@@ -289,7 +289,7 @@ class LoopGC(VM):
for
old_s
in
old_storage
:
for
old_s
in
old_storage
:
old_s
[
0
]
=
None
old_s
[
0
]
=
None
i
+=
1
i
+=
1
except
:
except
Exception
:
link
.
raise_with_op
(
node
,
thunk
)
link
.
raise_with_op
(
node
,
thunk
)
else
:
else
:
for
cont
in
self
.
pre_call_clear
:
for
cont
in
self
.
pre_call_clear
:
...
@@ -300,7 +300,7 @@ class LoopGC(VM):
...
@@ -300,7 +300,7 @@ class LoopGC(VM):
thunk
()
thunk
()
for
old_s
in
old_storage
:
for
old_s
in
old_storage
:
old_s
[
0
]
=
None
old_s
[
0
]
=
None
except
:
except
Exception
:
link
.
raise_with_op
(
node
,
thunk
)
link
.
raise_with_op
(
node
,
thunk
)
...
...
theano/scan_module/scan_opt.py
浏览文件 @
3ff31f1a
...
@@ -1007,7 +1007,7 @@ class ScanInplaceOptimizer(Optimizer):
...
@@ -1007,7 +1007,7 @@ class ScanInplaceOptimizer(Optimizer):
try
:
try
:
alloc_ops
+=
(
theano
.
gpuarray
.
GpuAlloc
,
alloc_ops
+=
(
theano
.
gpuarray
.
GpuAlloc
,
theano
.
gpuarray
.
GpuAllocEmpty
)
theano
.
gpuarray
.
GpuAllocEmpty
)
except
:
except
Exception
:
pass
pass
nodes
=
fgraph
.
toposort
()[::
-
1
]
nodes
=
fgraph
.
toposort
()[::
-
1
]
...
...
theano/tensor/basic.py
浏览文件 @
3ff31f1a
...
@@ -3838,7 +3838,7 @@ class Split(Op):
...
@@ -3838,7 +3838,7 @@ class Split(Op):
try
:
try
:
len_along_axis
=
x
.
shape
[
axis
]
len_along_axis
=
x
.
shape
[
axis
]
except
:
except
Exception
:
raise
ValueError
(
'Split.perform() with axis=(
%
s) is invalid'
raise
ValueError
(
'Split.perform() with axis=(
%
s) is invalid'
' for x.shape==(
%
s)'
' for x.shape==(
%
s)'
%
(
axis
,
x
.
shape
))
%
(
axis
,
x
.
shape
))
...
...
theano/tests/breakpoint.py
浏览文件 @
3ff31f1a
...
@@ -104,7 +104,7 @@ class PdbBreakpoint(Op):
...
@@ -104,7 +104,7 @@ class PdbBreakpoint(Op):
if
condition
:
if
condition
:
try
:
try
:
monitored
=
[
np
.
asarray
(
inp
)
for
inp
in
inputs
[
1
:]]
monitored
=
[
np
.
asarray
(
inp
)
for
inp
in
inputs
[
1
:]]
except
:
except
Exception
:
raise
ValueError
(
"Some of the inputs to the PdbBreakpoint op "
raise
ValueError
(
"Some of the inputs to the PdbBreakpoint op "
"'
%
s' could not be casted to NumPy arrays"
%
"'
%
s' could not be casted to NumPy arrays"
%
self
.
name
)
self
.
name
)
...
...
theano/tests/test_flake8.py
浏览文件 @
3ff31f1a
...
@@ -7,10 +7,15 @@ import os
...
@@ -7,10 +7,15 @@ import os
import
sys
import
sys
from
fnmatch
import
fnmatch
from
fnmatch
import
fnmatch
import
theano
import
theano
new_flake8
=
True
try
:
try
:
import
flake8.engine
import
flake8.main
import
flake8.main
flake8_available
=
True
flake8_available
=
True
try
:
import
flake8.engine
new_flake8
=
False
except
ImportError
:
import
flake8.api.legacy
except
ImportError
:
except
ImportError
:
flake8_available
=
False
flake8_available
=
False
...
@@ -29,9 +34,11 @@ __contact__ = "Saizheng Zhang <saizhenglisa..at..gmail.com>"
...
@@ -29,9 +34,11 @@ __contact__ = "Saizheng Zhang <saizhenglisa..at..gmail.com>"
# - "'division' present"
# - "'division' present"
# - "'absolute_import' present"
# - "'absolute_import' present"
# - "'print_function' present"
# - "'print_function' present"
# - "expected 2 blank lines after class or function definition"' (E305)
# - "ambiguous variable name" (E741)
# Redundant error code generated by flake8-future-import module
# Redundant error code generated by flake8-future-import module
ignore
=
(
'E501'
,
'E123'
,
'E133'
,
'FI12'
,
'FI14'
,
'FI15'
,
'FI16'
,
'FI17'
,
ignore
=
(
'E501'
,
'E123'
,
'E133'
,
'FI12'
,
'FI14'
,
'FI15'
,
'FI16'
,
'FI17'
,
'FI50'
,
'FI51'
,
'FI53'
)
'FI50'
,
'FI51'
,
'FI53'
,
'E305'
,
'E741'
)
whitelist_flake8
=
[
whitelist_flake8
=
[
"__init__.py"
,
"__init__.py"
,
...
@@ -126,6 +133,8 @@ def test_format_flake8():
...
@@ -126,6 +133,8 @@ def test_format_flake8():
if
not
flake8_available
:
if
not
flake8_available
:
raise
SkipTest
(
"flake8 is not installed"
)
raise
SkipTest
(
"flake8 is not installed"
)
total_errors
=
0
total_errors
=
0
files_to_checks
=
[]
for
path
in
list_files
():
for
path
in
list_files
():
rel_path
=
os
.
path
.
relpath
(
path
,
theano
.
__path__
[
0
])
rel_path
=
os
.
path
.
relpath
(
path
,
theano
.
__path__
[
0
])
if
sys
.
platform
==
'win32'
:
if
sys
.
platform
==
'win32'
:
...
@@ -133,8 +142,17 @@ def test_format_flake8():
...
@@ -133,8 +142,17 @@ def test_format_flake8():
if
rel_path
in
whitelist_flake8
:
if
rel_path
in
whitelist_flake8
:
continue
continue
else
:
else
:
files_to_checks
.
append
(
path
)
if
new_flake8
:
guide
=
flake8
.
api
.
legacy
.
get_style_guide
(
ignore
=
ignore
)
r
=
guide
.
check_files
(
files_to_checks
)
total_errors
=
r
.
total_errors
else
:
for
path
in
files_to_checks
:
error_num
=
flake8
.
main
.
check_file
(
path
,
ignore
=
ignore
)
error_num
=
flake8
.
main
.
check_file
(
path
,
ignore
=
ignore
)
total_errors
+=
error_num
total_errors
+=
error_num
if
total_errors
>
0
:
if
total_errors
>
0
:
raise
AssertionError
(
"FLAKE8 Format not respected"
)
raise
AssertionError
(
"FLAKE8 Format not respected"
)
...
...
theano/tests/test_gradient.py
浏览文件 @
3ff31f1a
...
@@ -75,7 +75,7 @@ class testgrad_sources_inputs(unittest.TestCase):
...
@@ -75,7 +75,7 @@ class testgrad_sources_inputs(unittest.TestCase):
# Test grad is called correctly for a 1-to-1 op
# Test grad is called correctly for a 1-to-1 op
gval
=
theano
.
tensor
.
matrix
()
gval
=
theano
.
tensor
.
matrix
()
class
O
(
gof
.
op
.
Op
):
class
TestOp
(
gof
.
op
.
Op
):
__props__
=
()
__props__
=
()
def
make_node
(
self
):
def
make_node
(
self
):
...
@@ -85,7 +85,7 @@ class testgrad_sources_inputs(unittest.TestCase):
...
@@ -85,7 +85,7 @@ class testgrad_sources_inputs(unittest.TestCase):
def
grad
(
self
,
inp
,
grads
):
def
grad
(
self
,
inp
,
grads
):
return
gval
,
return
gval
,
a1
=
O
()
.
make_node
()
a1
=
TestOp
()
.
make_node
()
g
=
grad_sources_inputs
([(
a1
.
outputs
[
0
],
one
)],
None
)
g
=
grad_sources_inputs
([(
a1
.
outputs
[
0
],
one
)],
None
)
self
.
assertTrue
(
g
[
a1
.
inputs
[
0
]]
is
gval
)
self
.
assertTrue
(
g
[
a1
.
inputs
[
0
]]
is
gval
)
...
@@ -93,7 +93,7 @@ class testgrad_sources_inputs(unittest.TestCase):
...
@@ -93,7 +93,7 @@ class testgrad_sources_inputs(unittest.TestCase):
# Test grad is called correctly for a 1-to-many op
# Test grad is called correctly for a 1-to-many op
gval
=
theano
.
tensor
.
matrix
()
gval
=
theano
.
tensor
.
matrix
()
class
O
(
gof
.
op
.
Op
):
class
TestOp
(
gof
.
op
.
Op
):
__props__
=
()
__props__
=
()
def
make_node
(
self
):
def
make_node
(
self
):
...
@@ -105,7 +105,7 @@ class testgrad_sources_inputs(unittest.TestCase):
...
@@ -105,7 +105,7 @@ class testgrad_sources_inputs(unittest.TestCase):
x
,
=
inp
x
,
=
inp
gz1
,
gz2
=
grads
gz1
,
gz2
=
grads
return
gval
,
return
gval
,
a1
=
O
()
.
make_node
()
a1
=
TestOp
()
.
make_node
()
g
=
grad_sources_inputs
([(
a1
.
outputs
[
0
],
one
)],
None
)
g
=
grad_sources_inputs
([(
a1
.
outputs
[
0
],
one
)],
None
)
self
.
assertTrue
(
g
[
a1
.
inputs
[
0
]]
is
gval
)
self
.
assertTrue
(
g
[
a1
.
inputs
[
0
]]
is
gval
)
...
@@ -114,7 +114,7 @@ class testgrad_sources_inputs(unittest.TestCase):
...
@@ -114,7 +114,7 @@ class testgrad_sources_inputs(unittest.TestCase):
gval0
=
theano
.
tensor
.
scalar
()
gval0
=
theano
.
tensor
.
scalar
()
gval1
=
theano
.
tensor
.
scalar
()
gval1
=
theano
.
tensor
.
scalar
()
class
O
(
gof
.
op
.
Op
):
class
TestOp
(
gof
.
op
.
Op
):
__props__
=
()
__props__
=
()
def
make_node
(
self
):
def
make_node
(
self
):
...
@@ -126,7 +126,7 @@ class testgrad_sources_inputs(unittest.TestCase):
...
@@ -126,7 +126,7 @@ class testgrad_sources_inputs(unittest.TestCase):
x0
,
x1
=
inp
x0
,
x1
=
inp
gz
,
=
grads
gz
,
=
grads
return
(
gval0
,
gval1
)
return
(
gval0
,
gval1
)
a1
=
O
()
.
make_node
()
a1
=
TestOp
()
.
make_node
()
g
=
grad_sources_inputs
([(
a1
.
outputs
[
0
],
one
)],
None
)
g
=
grad_sources_inputs
([(
a1
.
outputs
[
0
],
one
)],
None
)
self
.
assertTrue
(
g
[
a1
.
inputs
[
0
]]
is
gval0
)
self
.
assertTrue
(
g
[
a1
.
inputs
[
0
]]
is
gval0
)
self
.
assertTrue
(
g
[
a1
.
inputs
[
1
]]
is
gval1
)
self
.
assertTrue
(
g
[
a1
.
inputs
[
1
]]
is
gval1
)
...
@@ -136,7 +136,7 @@ class testgrad_sources_inputs(unittest.TestCase):
...
@@ -136,7 +136,7 @@ class testgrad_sources_inputs(unittest.TestCase):
gval0
=
theano
.
tensor
.
matrix
()
gval0
=
theano
.
tensor
.
matrix
()
gval1
=
theano
.
tensor
.
matrix
()
gval1
=
theano
.
tensor
.
matrix
()
class
O
(
gof
.
op
.
Op
):
class
TestOp
(
gof
.
op
.
Op
):
__props__
=
()
__props__
=
()
def
make_node
(
self
):
def
make_node
(
self
):
...
@@ -146,7 +146,7 @@ class testgrad_sources_inputs(unittest.TestCase):
...
@@ -146,7 +146,7 @@ class testgrad_sources_inputs(unittest.TestCase):
def
grad
(
self
,
inp
,
grads
):
def
grad
(
self
,
inp
,
grads
):
return
gval0
,
gval1
return
gval0
,
gval1
a1
=
O
()
.
make_node
()
a1
=
TestOp
()
.
make_node
()
g
=
grad_sources_inputs
([(
a1
.
outputs
[
0
],
one
)],
None
)
g
=
grad_sources_inputs
([(
a1
.
outputs
[
0
],
one
)],
None
)
self
.
assertTrue
(
g
[
a1
.
inputs
[
0
]]
is
gval0
)
self
.
assertTrue
(
g
[
a1
.
inputs
[
0
]]
is
gval0
)
self
.
assertTrue
(
g
[
a1
.
inputs
[
1
]]
is
gval1
)
self
.
assertTrue
(
g
[
a1
.
inputs
[
1
]]
is
gval1
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论