Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
bbca839e
提交
bbca839e
authored
7月 17, 2015
作者:
Frédéric Bastien
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3161 from lamblin/misc_fixes
Misc fixes for tests
上级
09446af5
0660048d
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
37 行增加
和
24 行删除
+37
-24
test_nanguardmode.py
theano/compile/tests/test_nanguardmode.py
+14
-17
test_pkl_utils.py
theano/misc/tests/test_pkl_utils.py
+21
-5
test_scan.py
theano/scan_module/tests/test_scan.py
+1
-1
test_tutorial.py
theano/tests/test_tutorial.py
+1
-1
没有找到文件。
theano/compile/tests/test_nanguardmode.py
浏览文件 @
bbca839e
"""
This test is for testing the NanGuardMode.
"""
from
theano.compile.nanguardmode
import
NanGuardMode
import
logging
from
nose.tools
import
assert_raises
import
numpy
from
theano.compile.nanguardmode
import
NanGuardMode
import
theano
import
theano.tensor
as
T
...
...
@@ -29,21 +33,14 @@ def test_NanGuardMode():
biga
=
numpy
.
tile
(
numpy
.
asarray
(
1e20
)
.
astype
(
theano
.
config
.
floatX
),
(
3
,
5
))
work
=
[
False
,
False
,
False
]
fun
(
a
)
# normal values
try
:
fun
(
infa
)
# INFs
except
AssertionError
:
work
[
0
]
=
True
try
:
fun
(
nana
)
# NANs
except
AssertionError
:
work
[
1
]
=
True
try
:
fun
(
biga
)
# big values
except
AssertionError
:
work
[
2
]
=
True
if
not
(
work
[
0
]
and
work
[
1
]
and
work
[
2
]):
raise
AssertionError
(
"NanGuardMode not working."
)
# Temporarily silence logger
_logger
=
logging
.
getLogger
(
"theano.compile.nanguardmode"
)
try
:
_logger
.
propagate
=
False
assert_raises
(
AssertionError
,
fun
,
infa
)
# INFs
assert_raises
(
AssertionError
,
fun
,
nana
)
# NANs
assert_raises
(
AssertionError
,
fun
,
biga
)
# big values
finally
:
_logger
.
propagate
=
True
theano/misc/tests/test_pkl_utils.py
浏览文件 @
bbca839e
import
os
import
shutil
import
unittest
from
tempfile
import
mkdtemp
import
numpy
from
numpy.testing
import
assert_allclose
from
nose.plugins.skip
import
SkipTest
...
...
@@ -11,7 +16,20 @@ from theano.sandbox.rng_mrg import MRG_RandomStreams
from
theano.misc.pkl_utils
import
dump
,
load
def
test_dump_load
():
class
T_dump_load
(
unittest
.
TestCase
):
def
setUp
(
self
):
# Work in a temporary directory to avoid cluttering the repository
self
.
origdir
=
os
.
getcwd
()
self
.
tmpdir
=
mkdtemp
()
os
.
chdir
(
self
.
tmpdir
)
def
tearDown
(
self
):
# Get back to the original dir, and delete the temporary one
os
.
chdir
(
self
.
origdir
)
if
self
.
tmpdir
is
not
None
:
shutil
.
rmtree
(
self
.
tmpdir
)
def
test_dump_load
(
self
):
if
not
cuda_ndarray
.
cuda_enabled
:
raise
SkipTest
(
'Optional package cuda disabled'
)
...
...
@@ -27,8 +45,7 @@ def test_dump_load():
assert
x
.
name
==
'x'
assert_allclose
(
x
.
get_value
(),
[[
1
]])
def
test_dump_load_mrg
():
def
test_dump_load_mrg
(
self
):
rng
=
MRG_RandomStreams
(
use_cuda
=
cuda_ndarray
.
cuda_enabled
)
with
open
(
'test'
,
'wb'
)
as
f
:
...
...
@@ -39,8 +56,7 @@ def test_dump_load_mrg():
assert
type
(
rng
)
==
MRG_RandomStreams
def
test_dump_zip_names
():
def
test_dump_zip_names
(
self
):
foo_1
=
theano
.
shared
(
0
,
name
=
'foo'
)
foo_2
=
theano
.
shared
(
1
,
name
=
'foo'
)
foo_3
=
theano
.
shared
(
2
,
name
=
'foo'
)
...
...
theano/scan_module/tests/test_scan.py
浏览文件 @
bbca839e
...
...
@@ -256,7 +256,7 @@ class T_Scan(unittest.TestCase):
finally
:
f_in
.
close
()
finally
:
# Get back to the ori
nal dir, and delet
e temporary one.
# Get back to the ori
ginal dir, and delete th
e temporary one.
os
.
chdir
(
origdir
)
if
tmpdir
is
not
None
:
shutil
.
rmtree
(
tmpdir
)
...
...
theano/tests/test_tutorial.py
浏览文件 @
bbca839e
...
...
@@ -878,7 +878,7 @@ class T_loading_and_saving(unittest.TestCase):
loaded_objects
.
append
(
pickle
.
load
(
f
))
f
.
close
()
finally
:
# Get back to the ori
nal dir, and
temporary one.
# Get back to the ori
ginal dir, and delete the
temporary one.
os
.
chdir
(
origdir
)
if
tmpdir
is
not
None
:
shutil
.
rmtree
(
tmpdir
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论