Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e2071e88
提交
e2071e88
authored
2月 24, 2012
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
New theano.test function, captures stdout.
We used to re-use numpy.test mechanism, but it was not really suited to Theano. Now we use a subclass of NumPy's one, with code copied and adapted from NumPy.
上级
a4a3b5eb
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
130 行增加
和
4 行删除
+130
-4
LICENSE.txt
doc/LICENSE.txt
+3
-0
__init__.py
theano/__init__.py
+2
-2
__init__.py
theano/tests/__init__.py
+1
-1
main.py
theano/tests/main.py
+124
-1
没有找到文件。
doc/LICENSE.txt
浏览文件 @
e2071e88
...
...
@@ -6,6 +6,9 @@ LICENSE
Copyright (c) 2008--2012, Theano Development Team
All rights reserved.
Contains code from NumPy, Copyright (c) 2005-2011, NumPy Developers.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
...
...
theano/__init__.py
浏览文件 @
e2071e88
...
...
@@ -77,8 +77,8 @@ from compile import \
from
misc.safe_asarray
import
_asarray
import
numpy.testing
test
=
numpy
.
testing
.
Tester
()
.
test
import
theano.tests
test
=
theano
.
tests
.
TheanoNose
Tester
()
.
test
FancyModule
=
Module
...
...
theano/tests/__init__.py
浏览文件 @
e2071e88
from
main
import
main
from
main
import
main
,
TheanoNoseTester
import
unittest_tools
theano/tests/main.py
浏览文件 @
e2071e88
import
unittest
,
sys
import
os
,
unittest
,
sys
import
nose.plugins.builtin
from
numpy.testing.nosetester
import
import_nose
,
NoseTester
from
numpy.testing.noseclasses
import
KnownFailure
,
NumpyTestProgram
class
TheanoNoseTester
(
NoseTester
):
"""
Nose test runner.
This class enables running nose tests from inside Theano,
by calling theano.test().
This version is more adapted to what we want than Numpy's one.
"""
def
_test_argv
(
self
,
verbose
,
extra_argv
):
"""
Generate argv for nosetest command
:type verbose: int
:param verbose: Verbosity value for test outputs, in the range 1-10.
Default is 1.
:type extra_argv: list
:param extra_argv: List with any extra arguments to pass to nosetests.
"""
#self.package_path = os.path.abspath(self.package_path)
argv
=
[
__file__
,
self
.
package_path
]
argv
+=
[
'--verbosity'
,
str
(
verbose
)]
if
extra_argv
:
argv
+=
extra_argv
return
argv
def
_show_system_info
(
self
):
nose
=
import_nose
()
import
theano
print
"Theano version
%
s"
%
theano
.
__version__
theano_dir
=
os
.
path
.
dirname
(
theano
.
__file__
)
print
"theano is installed in
%
s"
%
theano_dir
super
(
TheanoNoseTester
,
self
)
.
_show_system_info
()
def
prepare_test_args
(
self
,
verbose
=
1
,
extra_argv
=
None
,
coverage
=
False
,
capture
=
True
,
knownfailure
=
True
):
"""
Prepare arguments for the `test` method.
Takes the same arguments as `test`.
"""
# fail with nice error message if nose is not present
nose
=
import_nose
()
# compile argv
argv
=
self
.
_test_argv
(
verbose
,
extra_argv
)
# numpy way of doing coverage
if
coverage
:
argv
+=
[
'--cover-package=
%
s'
%
self
.
package_name
,
'--with-coverage'
,
'--cover-tests'
,
'--cover-inclusive'
,
'--cover-erase'
]
# Capture output only if needed
if
not
capture
:
argv
+=
[
'-s'
]
# construct list of plugins
plugins
=
[]
if
knownfailure
:
plugins
.
append
(
KnownFailure
())
plugins
+=
[
p
()
for
p
in
nose
.
plugins
.
builtin
.
plugins
]
return
argv
,
plugins
def
test
(
self
,
verbose
=
1
,
extra_argv
=
None
,
coverage
=
False
,
capture
=
True
,
knownfailure
=
True
):
"""
Run tests for module using nose.
:type verbose: int
:param verbose: Verbosity value for test outputs, in the range 1-10.
Default is 1.
:type extra_argv: list
:param extra_argv: List with any extra arguments to pass to nosetests.
:type coverage: bool
:param coverage: If True, report coverage of Theano code. Default is False.
:type capture: bool
:param capture: If True, capture the standard output of the tests, like
nosetests does in command-line. The output of failing
tests will be displayed at the end. Default is True.
:type knownfailure: bool
:param knownfailure: If True, tests raising KnownFailureTest will
not be considered Errors nor Failure, but reported as
"known failures" and treated quite like skipped tests.
Default is True.
:returns: Returns the result of running the tests as a
``nose.result.TextTestResult`` object.
"""
# cap verbosity at 3 because nose becomes *very* verbose beyond that
verbose
=
min
(
verbose
,
3
)
self
.
_show_system_info
()
cwd
=
os
.
getcwd
()
if
self
.
package_path
in
os
.
listdir
(
cwd
):
# The tests give weird errors if the package to test is
# in current directory.
raise
RuntimeError
((
"This function does not run correctly when, at the time "
"theano was imported, the working directory was theano's "
"parent directory. You should exit your Python prompt, change "
"directory, then launch Python again, import theano, then "
"launch theano.test()."
))
argv
,
plugins
=
self
.
prepare_test_args
(
verbose
,
extra_argv
,
coverage
,
capture
,
knownfailure
)
t
=
NumpyTestProgram
(
argv
=
argv
,
exit
=
False
,
plugins
=
plugins
)
return
t
.
result
def
main
(
modulename
):
debug
=
False
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论