Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
30d9450a
提交
30d9450a
authored
3月 09, 2016
作者:
Francesco
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4190 from taesupkim/issue_4185
flake8 misc/tests/*.py
上级
954c3816
56a61490
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
41 行增加
和
41 行删除
+41
-41
test_cudamat_utils.py
theano/misc/tests/test_cudamat_utils.py
+10
-9
test_gnumpy_utils.py
theano/misc/tests/test_gnumpy_utils.py
+2
-2
test_may_share_memory.py
theano/misc/tests/test_may_share_memory.py
+21
-16
test_pycuda_example.py
theano/misc/tests/test_pycuda_example.py
+2
-3
test_pycuda_theano_simple.py
theano/misc/tests/test_pycuda_theano_simple.py
+2
-2
test_pycuda_utils.py
theano/misc/tests/test_pycuda_utils.py
+4
-3
test_flake8.py
theano/tests/test_flake8.py
+0
-6
没有找到文件。
theano/misc/tests/test_cudamat_utils.py
浏览文件 @
30d9450a
import
numpy
import
numpy
import
theano
import
theano
from
theano.misc.cudamat_utils
import
cudamat_available
from
theano.misc.cudamat_utils
import
cudamat_available
if
not
cudamat_available
:
if
not
cudamat_available
:
# noqa
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
raise
SkipTest
(
"gnumpy not installed. Skip test of theano op with pycuda code."
)
raise
SkipTest
(
"gnumpy not installed. Skip test of theano op with pycuda "
"code."
)
from
theano.misc.cudamat_utils
import
cudandarray_to_cudamat
,
cudamat_to_cudandarray
from
theano.misc.cudamat_utils
import
(
cudandarray_to_cudamat
,
cudamat_to_cudandarray
)
def
test
(
shape
=
(
3
,
4
)):
def
test
(
shape
=
(
3
,
4
)):
"""
"""
Make sure that the cudamat conversion is exact.
Make sure that the cudamat conversion is exact.
"""
"""
gpu
=
theano
.
sandbox
.
cuda
.
basic_ops
.
gpu_from_host
gpu
=
theano
.
sandbox
.
cuda
.
basic_ops
.
gpu_from_host
U
=
gpu
(
theano
.
tensor
.
fmatrix
(
'U'
))
U
=
gpu
(
theano
.
tensor
.
fmatrix
(
'U'
))
ii
=
theano
.
function
([
U
],
gpu
(
U
+
1
))
ii
=
theano
.
function
([
U
],
gpu
(
U
+
1
))
A_cpu
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
*
shape
),
dtype
=
"float32"
)
A_cpu
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
*
shape
),
dtype
=
"float32"
)
A_cnd
=
theano
.
sandbox
.
cuda
.
CudaNdarray
(
A_cpu
)
A_cnd
=
theano
.
sandbox
.
cuda
.
CudaNdarray
(
A_cpu
)
...
@@ -31,5 +32,5 @@ Make sure that the cudamat conversion is exact.
...
@@ -31,5 +32,5 @@ Make sure that the cudamat conversion is exact.
v
=
numpy
.
asarray
(
B_cnd
)
v
=
numpy
.
asarray
(
B_cnd
)
w
=
A_cmat
.
add
(
1
)
.
asarray
()
w
=
A_cmat
.
add
(
1
)
.
asarray
()
assert
abs
(
u
-
v
)
.
max
()
==
0
assert
abs
(
u
-
v
)
.
max
()
==
0
assert
abs
(
u
-
w
.
T
.
reshape
(
u
.
shape
))
.
max
()
==
0
assert
abs
(
u
-
w
.
T
.
reshape
(
u
.
shape
))
.
max
()
==
0
theano/misc/tests/test_gnumpy_utils.py
浏览文件 @
30d9450a
...
@@ -3,7 +3,7 @@ import numpy
...
@@ -3,7 +3,7 @@ import numpy
import
theano
import
theano
from
theano.misc.gnumpy_utils
import
gnumpy_available
from
theano.misc.gnumpy_utils
import
gnumpy_available
if
not
gnumpy_available
:
if
not
gnumpy_available
:
# noqa
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
raise
SkipTest
(
"gnumpy not installed. Skip test related to it."
)
raise
SkipTest
(
"gnumpy not installed. Skip test related to it."
)
...
@@ -46,7 +46,7 @@ def test2(shape=(3, 4, 5)):
...
@@ -46,7 +46,7 @@ def test2(shape=(3, 4, 5)):
"""
"""
gpu
=
theano
.
sandbox
.
cuda
.
basic_ops
.
gpu_from_host
gpu
=
theano
.
sandbox
.
cuda
.
basic_ops
.
gpu_from_host
U
=
gpu
(
theano
.
tensor
.
ftensor3
(
'U'
))
U
=
gpu
(
theano
.
tensor
.
ftensor3
(
'U'
))
ii
=
theano
.
function
([
U
],
gpu
(
U
+
1
))
theano
.
function
([
U
],
gpu
(
U
+
1
))
A
=
numpy
.
random
.
rand
(
*
shape
)
.
astype
(
'float32'
)
A
=
numpy
.
random
.
rand
(
*
shape
)
.
astype
(
'float32'
)
A_cnd
=
theano
.
sandbox
.
cuda
.
CudaNdarray
(
A
)
A_cnd
=
theano
.
sandbox
.
cuda
.
CudaNdarray
(
A
)
...
...
theano/misc/tests/test_may_share_memory.py
浏览文件 @
30d9450a
"""
"""
test the tensor and sparse type. The CudaNdarray type is tested in sandbox/cuda/tests/test_tensor_op.py.test_may_share_memory_cuda
test the tensor and sparse type. The CudaNdarray type is tested in
sandbox/cuda/tests/test_tensor_op.py.test_may_share_memory_cuda
"""
"""
import
numpy
import
numpy
import
theano
import
theano
try
:
try
:
...
@@ -26,12 +25,12 @@ def test_may_share_memory():
...
@@ -26,12 +25,12 @@ def test_may_share_memory():
tb
=
b
.
T
tb
=
b
.
T
for
a_
,
b_
,
rep
in
[(
a
,
a
,
True
),
(
b
,
b
,
True
),
(
a
,
b
,
False
),
for
a_
,
b_
,
rep
in
[(
a
,
a
,
True
),
(
b
,
b
,
True
),
(
a
,
b
,
False
),
(
a
,
a
[
0
],
True
),
(
a
,
a
[:,
0
],
True
),
(
a
,
a
.
T
,
True
),
(
a
,
a
[
0
],
True
),
(
a
,
a
[:,
0
],
True
),
(
a
,
a
.
T
,
True
),
(
a
,
(
0
,),
False
),
(
a
,
1
,
False
),
(
a
,
None
,
False
),
(
a
,
(
0
,),
False
),
(
a
,
1
,
False
),
(
a
,
None
,
False
),
(
a
,
va
,
True
),
(
b
,
vb
,
True
),
(
va
,
b
,
False
),
(
a
,
v
b
,
False
),
(
a
,
va
,
True
),
(
b
,
vb
,
True
),
(
va
,
b
,
False
),
(
a
,
ra
,
True
),
(
b
,
rb
,
True
),
(
ra
,
b
,
False
),
(
a
,
rb
,
Fals
e
),
(
a
,
vb
,
False
),
(
a
,
ra
,
True
),
(
b
,
rb
,
Tru
e
),
(
a
,
ta
,
True
),
(
b
,
tb
,
True
),
(
ta
,
b
,
False
),
(
a
,
tb
,
Fals
e
),
(
ra
,
b
,
False
),
(
a
,
rb
,
False
),
(
a
,
ta
,
Tru
e
),
]:
(
b
,
tb
,
True
),
(
ta
,
b
,
False
),
(
a
,
tb
,
False
)
]:
assert
may_share_memory
(
a_
,
b_
,
False
)
==
rep
assert
may_share_memory
(
a_
,
b_
,
False
)
==
rep
assert
may_share_memory
(
b_
,
a_
,
False
)
==
rep
assert
may_share_memory
(
b_
,
a_
,
False
)
==
rep
...
@@ -55,14 +54,20 @@ if scipy_imported:
...
@@ -55,14 +54,20 @@ if scipy_imported:
def
test_may_share_memory_scipy
():
def
test_may_share_memory_scipy
():
a
=
scipy
.
sparse
.
csc_matrix
(
scipy
.
sparse
.
eye
(
5
,
3
))
a
=
scipy
.
sparse
.
csc_matrix
(
scipy
.
sparse
.
eye
(
5
,
3
))
b
=
scipy
.
sparse
.
csc_matrix
(
scipy
.
sparse
.
eye
(
4
,
3
))
b
=
scipy
.
sparse
.
csc_matrix
(
scipy
.
sparse
.
eye
(
4
,
3
))
as_ar
=
lambda
a
:
theano
.
_asarray
(
a
,
dtype
=
'int32'
)
def
as_ar
(
a
):
return
theano
.
_asarray
(
a
,
dtype
=
'int32'
)
for
a_
,
b_
,
rep
in
[(
a
,
a
,
True
),
(
b
,
b
,
True
),
(
a
,
b
,
False
),
for
a_
,
b_
,
rep
in
[(
a
,
a
,
True
),
(
b
,
b
,
True
),
(
a
,
b
,
False
),
(
a
,
a
.
data
,
True
),
(
a
,
a
.
indptr
,
True
),
(
a
,
a
.
indices
,
True
),
(
a
,
as_ar
(
a
.
shape
),
False
),
(
a
,
a
.
data
,
True
),
(
a
,
a
.
indptr
,
True
),
(
a
.
data
,
a
,
True
),
(
a
.
indptr
,
a
,
True
),
(
a
.
indices
,
a
,
True
),
(
as_ar
(
a
.
shape
),
a
,
False
),
(
a
,
a
.
indices
,
True
),
(
a
,
as_ar
(
a
.
shape
),
False
),
(
b
,
b
.
data
,
True
),
(
b
,
b
.
indptr
,
True
),
(
b
,
b
.
indices
,
True
),
(
b
,
as_ar
(
b
.
shape
),
False
),
(
a
.
data
,
a
,
True
),
(
a
.
indptr
,
a
,
True
),
(
b
.
data
,
b
,
True
),
(
b
.
indptr
,
b
,
True
),
(
b
.
indices
,
b
,
True
),
(
as_ar
(
b
.
shape
),
b
,
False
),
(
a
.
indices
,
a
,
True
),
(
as_ar
(
a
.
shape
),
a
,
False
),
(
b
.
data
,
a
,
False
),
(
b
.
indptr
,
a
,
False
),
(
b
.
indices
,
a
,
False
),
(
as_ar
(
b
.
shape
),
a
,
False
),
(
b
,
b
.
data
,
True
),
(
b
,
b
.
indptr
,
True
),
]:
(
b
,
b
.
indices
,
True
),
(
b
,
as_ar
(
b
.
shape
),
False
),
(
b
.
data
,
b
,
True
),
(
b
.
indptr
,
b
,
True
),
(
b
.
indices
,
b
,
True
),
(
as_ar
(
b
.
shape
),
b
,
False
),
(
b
.
data
,
a
,
False
),
(
b
.
indptr
,
a
,
False
),
(
b
.
indices
,
a
,
False
),
(
as_ar
(
b
.
shape
),
a
,
False
)]:
assert
may_share_memory
(
a_
,
b_
)
==
rep
assert
may_share_memory
(
a_
,
b_
)
==
rep
assert
may_share_memory
(
b_
,
a_
)
==
rep
assert
may_share_memory
(
b_
,
a_
)
==
rep
...
...
theano/misc/tests/test_pycuda_example.py
浏览文件 @
30d9450a
...
@@ -4,19 +4,18 @@ import numpy
...
@@ -4,19 +4,18 @@ import numpy
import
theano
import
theano
import
theano.misc.pycuda_init
import
theano.misc.pycuda_init
if
not
theano
.
misc
.
pycuda_init
.
pycuda_available
:
if
not
theano
.
misc
.
pycuda_init
.
pycuda_available
:
# noqa
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
raise
SkipTest
(
"Pycuda not installed. Skip test of theano op"
raise
SkipTest
(
"Pycuda not installed. Skip test of theano op"
" with pycuda code."
)
" with pycuda code."
)
import
theano.sandbox.cuda
as
cuda_ndarray
import
theano.sandbox.cuda
as
cuda_ndarray
if
not
cuda_ndarray
.
cuda_available
:
if
not
cuda_ndarray
.
cuda_available
:
# noqa
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
raise
SkipTest
(
'Optional package cuda disabled'
)
raise
SkipTest
(
'Optional package cuda disabled'
)
import
theano.tensor
as
T
import
theano.tensor
as
T
from
theano.misc.pycuda_example
import
(
PycudaElemwiseSourceModuleOp
,
from
theano.misc.pycuda_example
import
(
PycudaElemwiseSourceModuleOp
,
# PycudaElemwiseKernelOp,
PycudaElemwiseSourceModuleMakeThunkOp
)
PycudaElemwiseSourceModuleMakeThunkOp
)
if
theano
.
config
.
mode
==
'FAST_COMPILE'
:
if
theano
.
config
.
mode
==
'FAST_COMPILE'
:
...
...
theano/misc/tests/test_pycuda_theano_simple.py
浏览文件 @
30d9450a
...
@@ -14,12 +14,12 @@ import theano
...
@@ -14,12 +14,12 @@ import theano
import
theano.sandbox.cuda
as
cuda_ndarray
import
theano.sandbox.cuda
as
cuda_ndarray
import
theano.misc.pycuda_init
import
theano.misc.pycuda_init
if
not
theano
.
misc
.
pycuda_init
.
pycuda_available
:
if
not
theano
.
misc
.
pycuda_init
.
pycuda_available
:
# noqa
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
raise
SkipTest
(
"Pycuda not installed."
raise
SkipTest
(
"Pycuda not installed."
" We skip tests of Theano Ops with pycuda code."
)
" We skip tests of Theano Ops with pycuda code."
)
if
cuda_ndarray
.
cuda_available
==
False
:
if
cuda_ndarray
.
cuda_available
is
False
:
# noqa
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
raise
SkipTest
(
'Optional theano package cuda disabled'
)
raise
SkipTest
(
'Optional theano package cuda disabled'
)
...
...
theano/misc/tests/test_pycuda_utils.py
浏览文件 @
30d9450a
...
@@ -3,11 +3,12 @@ import numpy
...
@@ -3,11 +3,12 @@ import numpy
import
theano.sandbox.cuda
as
cuda
import
theano.sandbox.cuda
as
cuda
import
theano.misc.pycuda_init
import
theano.misc.pycuda_init
if
not
theano
.
misc
.
pycuda_init
.
pycuda_available
:
if
not
theano
.
misc
.
pycuda_init
.
pycuda_available
:
# noqa
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
raise
SkipTest
(
"Pycuda not installed. Skip test of theano op with pycuda code."
)
raise
SkipTest
(
"Pycuda not installed. Skip test of theano op with pycuda "
"code."
)
if
cuda
.
cuda_available
==
False
:
if
cuda
.
cuda_available
is
False
:
# noqa
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
raise
SkipTest
(
'Optional theano package cuda disabled'
)
raise
SkipTest
(
'Optional theano package cuda disabled'
)
...
...
theano/tests/test_flake8.py
浏览文件 @
30d9450a
...
@@ -149,12 +149,6 @@ whitelist_flake8 = [
...
@@ -149,12 +149,6 @@ whitelist_flake8 = [
"scan_module/__init__.py"
,
"scan_module/__init__.py"
,
"scan_module/tests/test_scan.py"
,
"scan_module/tests/test_scan.py"
,
"scan_module/tests/test_scan_opt.py"
,
"scan_module/tests/test_scan_opt.py"
,
"misc/tests/test_may_share_memory.py"
,
"misc/tests/test_pycuda_theano_simple.py"
,
"misc/tests/test_gnumpy_utils.py"
,
"misc/tests/test_pycuda_utils.py"
,
"misc/tests/test_cudamat_utils.py"
,
"misc/tests/test_pycuda_example.py"
,
"misc/hooks/reindent.py"
,
"misc/hooks/reindent.py"
,
"misc/hooks/check_whitespace.py"
,
"misc/hooks/check_whitespace.py"
,
"sparse/__init__.py"
,
"sparse/__init__.py"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论