Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b461908b
提交
b461908b
authored
7月 20, 2017
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Disable compute_test_value for test that expect errors.
上级
749a492d
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
46 行增加
和
38 行删除
+46
-38
test_neighbours.py
theano/tensor/nnet/tests/test_neighbours.py
+3
-0
test_basic.py
theano/tensor/tests/test_basic.py
+18
-14
test_mpi.py
theano/tensor/tests/test_mpi.py
+5
-0
test_opt.py
theano/tensor/tests/test_opt.py
+3
-1
test_subtensor.py
theano/tensor/tests/test_subtensor.py
+17
-23
没有找到文件。
theano/tensor/nnet/tests/test_neighbours.py
浏览文件 @
b461908b
...
...
@@ -8,6 +8,7 @@ import theano.tensor as T
from
theano.tensor.nnet.neighbours
import
images2neibs
,
neibs2images
,
Images2Neibs
from
theano.tests
import
unittest_tools
from
theano.configparser
import
change_flags
mode_without_gpu
=
theano
.
compile
.
mode
.
get_default_mode
()
.
excluding
(
'gpu'
)
...
...
@@ -140,6 +141,7 @@ class T_Images2Neibs(unittest_tools.InferShapeTester):
# print g()
# assert numpy.allclose(images.get_value(borrow=True), g())
@change_flags
(
compute_test_value
=
'off'
)
def
test_neibs_bad_shape
(
self
):
shape
=
(
2
,
3
,
10
,
10
)
for
dtype
in
self
.
dtypes
:
...
...
@@ -287,6 +289,7 @@ class T_Images2Neibs(unittest_tools.InferShapeTester):
f_full
=
theano
.
function
([],
x_using_full
,
mode
=
self
.
mode
)
unittest_tools
.
assert_allclose
(
f_valid
(),
f_full
())
@change_flags
(
compute_test_value
=
'off'
)
def
test_neibs_bad_shape_wrap_centered
(
self
):
shape
=
(
2
,
3
,
10
,
10
)
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
b461908b
...
...
@@ -57,7 +57,7 @@ from theano.tensor import (
from
theano.tests
import
unittest_tools
as
utt
from
theano.tests.unittest_tools
import
attr
from
theano.configparser
import
change_flags
imported_scipy_special
=
False
mode_no_scipy
=
get_default_mode
()
...
...
@@ -443,6 +443,7 @@ def makeTester(name, op, expected, checks=None, good=None, bad_build=None,
# instantiated on the following bad inputs: %s"
# % (self.op, testname, node, inputs))
@change_flags
(
compute_test_value
=
'off'
)
def
test_bad_runtime
(
self
):
if
skip
:
raise
SkipTest
(
skip
)
...
...
@@ -4383,14 +4384,15 @@ class T_Join_and_Split(unittest.TestCase):
for
node
in
topo
:
assert
not
isinstance
(
node
.
op
,
type
(
self
.
join_op
))
# Test hide error
x1
.
set_value
(
get_mat
(
3
,
4
))
x2
.
set_value
(
get_mat
(
3
,
4
))
x3
.
set_value
(
get_mat
(
2
,
5
))
if
not
self
.
hide_error
:
self
.
assertRaises
(
ValueError
,
f
)
else
:
f
()
with
change_flags
(
compute_test_value
=
'off'
):
# Test hide error
x1
.
set_value
(
get_mat
(
3
,
4
))
x2
.
set_value
(
get_mat
(
3
,
4
))
x3
.
set_value
(
get_mat
(
2
,
5
))
if
not
self
.
hide_error
:
self
.
assertRaises
(
ValueError
,
f
)
else
:
f
()
def
test_rebroadcast
(
self
):
# Regression test for a crash that used to happen when rebroadcasting.
...
...
@@ -4432,6 +4434,7 @@ class T_Join_and_Split(unittest.TestCase):
assert
np
.
allclose
(
o1
,
m
.
get_value
(
borrow
=
True
))
assert
np
.
allclose
(
o2
,
m
.
get_value
(
borrow
=
True
)[
4
:])
@change_flags
(
compute_test_value
=
'off'
)
def
test_split_neg
(
self
):
rng
=
np
.
random
.
RandomState
(
seed
=
utt
.
fetch_seed
())
m
=
self
.
shared
(
rng
.
rand
(
4
,
6
)
.
astype
(
self
.
floatX
))
...
...
@@ -7321,11 +7324,12 @@ class T_get_scalar_constant_value(unittest.TestCase):
a
=
opt
.
Assert
()(
c
,
c
>
1
)
assert
get_scalar_constant_value
(
a
)
==
2
# condition is always False
a
=
opt
.
Assert
()(
c
,
c
>
2
)
self
.
assertRaises
(
tensor
.
NotScalarConstantError
,
get_scalar_constant_value
,
a
)
with
change_flags
(
compute_test_value
=
'off'
):
# condition is always False
a
=
opt
.
Assert
()(
c
,
c
>
2
)
self
.
assertRaises
(
tensor
.
NotScalarConstantError
,
get_scalar_constant_value
,
a
)
# condition is not constant
a
=
opt
.
Assert
()(
c
,
c
>
x
)
...
...
theano/tensor/tests/test_mpi.py
浏览文件 @
b461908b
...
...
@@ -6,11 +6,14 @@ import subprocess
import
os
from
theano.gof.sched
import
sort_schedule_fn
from
theano.configparser
import
change_flags
mpi_scheduler
=
sort_schedule_fn
(
*
mpi_cmps
)
mpi_linker
=
theano
.
OpWiseCLinker
(
schedule
=
mpi_scheduler
)
mpi_mode
=
theano
.
Mode
(
linker
=
mpi_linker
)
@change_flags
(
compute_test_value
=
'off'
)
def
test_recv
():
x
=
recv
((
10
,
10
),
'float64'
,
0
,
11
)
assert
x
.
dtype
==
'float64'
...
...
@@ -29,6 +32,7 @@ def test_send():
assert
sendnode
.
op
.
tag
==
11
@change_flags
(
compute_test_value
=
'off'
)
def
test_can_make_function
():
x
=
recv
((
5
,
5
),
'float32'
,
0
,
11
)
y
=
x
+
1
...
...
@@ -61,6 +65,7 @@ def test_mpi_send_wait_cmp():
assert
mpi_send_wait_cmp
(
waitnode
,
addnode
)
>
0
# wait happens last
@change_flags
(
compute_test_value
=
'off'
)
def
test_mpi_tag_ordering
():
x
=
recv
((
2
,
2
),
'float32'
,
1
,
12
)
y
=
recv
((
2
,
2
),
'float32'
,
1
,
11
)
...
...
theano/tensor/tests/test_opt.py
浏览文件 @
b461908b
...
...
@@ -63,6 +63,7 @@ from theano.tensor.elemwise import DimShuffle
from
theano.tensor.type
import
values_eq_approx_remove_nan
from
theano.tests
import
unittest_tools
as
utt
from
theano.gof.opt
import
check_stack_trace
,
out2in
from
theano.configparser
import
change_flags
from
nose.plugins.attrib
import
attr
mode_opt
=
theano
.
config
.
mode
...
...
@@ -3685,6 +3686,7 @@ class Test_local_canonicalize_alloc(unittest.TestCase):
def
setUp
(
self
):
self
.
rng
=
np
.
random
.
RandomState
(
utt
.
fetch_seed
())
@change_flags
(
compute_test_value
=
'off'
)
def
test0
(
self
):
x
=
shared
(
self
.
rng
.
randn
(
3
,
7
))
a
=
tensor
.
alloc
(
x
,
6
,
7
)
...
...
@@ -5602,7 +5604,7 @@ class T_local_opt_alloc(unittest.TestCase):
finally
:
theano
.
config
.
warn_float64
=
orig
@
theano.configparser.
change_flags
(
on_opt_error
=
'raise'
)
@change_flags
(
on_opt_error
=
'raise'
)
def
test_sum_bool_upcast
(
self
):
s
=
theano
.
tensor
.
lscalar
()
a
=
theano
.
tensor
.
alloc
(
np
.
asarray
(
True
,
dtype
=
'bool'
),
s
,
s
)
...
...
theano/tensor/tests/test_subtensor.py
浏览文件 @
b461908b
...
...
@@ -34,6 +34,7 @@ from theano.tensor.subtensor import (AdvancedIncSubtensor,
from
theano.tensor.tests.test_basic
import
inplace_func
,
rand
,
randint_ranged
from
theano.tests
import
unittest_tools
as
utt
from
theano.tests.unittest_tools
import
attr
from
theano.configparser
import
change_flags
if
PY3
:
def
L
(
i
):
...
...
@@ -126,14 +127,10 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
return
self
.
fail
()
@change_flags
(
compute_test_value
=
'off'
)
def
test1_err_bounds
(
self
):
n
=
self
.
shared
(
np
.
ones
(
3
,
dtype
=
self
.
dtype
))
ctv_backup
=
config
.
compute_test_value
config
.
compute_test_value
=
'off'
try
:
t
=
n
[
7
]
finally
:
config
.
compute_test_value
=
ctv_backup
t
=
n
[
7
]
self
.
assertTrue
(
isinstance
(
t
.
owner
.
op
,
Subtensor
))
# Silence expected error messages
_logger
=
logging
.
getLogger
(
'theano.gof.opt'
)
...
...
@@ -223,26 +220,23 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
self
.
assertTrue
(
tval
.
shape
==
(
2
,))
self
.
assertTrue
((
tval
==
[
0.0
,
2.0
])
.
all
())
@change_flags
(
compute_test_value
=
'off'
)
def
test2_err_bounds0
(
self
):
n
=
self
.
shared
(
np
.
ones
((
2
,
3
),
dtype
=
self
.
dtype
)
*
5
)
ctv_backup
=
config
.
compute_test_value
config
.
compute_test_value
=
'off'
try
:
for
idx
in
[(
0
,
4
),
(
0
,
-
4
)]:
t
=
n
[
idx
]
self
.
assertTrue
(
isinstance
(
t
.
owner
.
op
,
Subtensor
))
# Silence expected warnings
_logger
=
logging
.
getLogger
(
'theano.gof.opt'
)
oldlevel
=
_logger
.
level
_logger
.
setLevel
(
logging
.
CRITICAL
)
try
:
self
.
assertRaises
(
IndexError
,
self
.
eval_output_and_check
,
[
t
])
finally
:
_logger
.
setLevel
(
oldlevel
)
finally
:
config
.
compute_test_value
=
ctv_backup
for
idx
in
[(
0
,
4
),
(
0
,
-
4
)]:
t
=
n
[
idx
]
self
.
assertTrue
(
isinstance
(
t
.
owner
.
op
,
Subtensor
))
# Silence expected warnings
_logger
=
logging
.
getLogger
(
'theano.gof.opt'
)
oldlevel
=
_logger
.
level
_logger
.
setLevel
(
logging
.
CRITICAL
)
try
:
self
.
assertRaises
(
IndexError
,
self
.
eval_output_and_check
,
[
t
])
finally
:
_logger
.
setLevel
(
oldlevel
)
@change_flags
(
compute_test_value
=
'off'
)
def
test2_err_bounds1
(
self
):
n
=
self
.
shared
((
np
.
ones
((
2
,
3
),
dtype
=
self
.
dtype
)
*
5
))
t
=
n
[
4
:
5
,
3
]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论