Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f1be580c
提交
f1be580c
authored
2月 28, 2011
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
skip test instead of disabling them when scipy is not there.
上级
178119c9
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
39 行增加
和
20 行删除
+39
-20
test_basic.py
theano/tensor/tests/test_basic.py
+39
-20
没有找到文件。
theano/tensor/tests/test_basic.py
浏览文件 @
f1be580c
...
@@ -3,6 +3,7 @@ import StringIO
...
@@ -3,6 +3,7 @@ import StringIO
import
sys
import
sys
import
unittest
import
unittest
from
nose.plugins.skip
import
SkipTest
import
numpy
import
numpy
from
numpy.testing
import
dec
from
numpy.testing
import
dec
...
@@ -61,12 +62,13 @@ def safe_make_node(op, *inputs):
...
@@ -61,12 +62,13 @@ def safe_make_node(op, *inputs):
return
node
[
0
]
.
owner
return
node
[
0
]
.
owner
else
:
else
:
return
node
.
owner
return
node
.
owner
def
makeTester
(
name
,
op
,
expected
,
checks
=
{},
good
=
{},
bad_build
=
{},
def
makeTester
(
name
,
op
,
expected
,
checks
=
{},
good
=
{},
bad_build
=
{},
bad_runtime
=
{},
grad
=
{},
mode
=
None
,
grad_rtol
=
None
,
eps
=
1e-10
):
bad_runtime
=
{},
grad
=
{},
mode
=
None
,
grad_rtol
=
None
,
eps
=
1e-10
,
skip
=
False
):
if
grad
is
True
:
if
grad
is
True
:
grad
=
good
grad
=
good
_op
,
_expected
,
_checks
,
_good
,
_bad_build
,
_bad_runtime
,
_grad
,
_mode
,
_grad_rtol
,
_eps
=
op
,
expected
,
checks
,
good
,
bad_build
,
bad_runtime
,
grad
,
mode
,
grad_rtol
,
eps
_op
,
_expected
,
_checks
,
_good
,
_bad_build
,
_bad_runtime
,
_grad
,
_mode
,
_grad_rtol
,
_eps
,
skip_
=
op
,
expected
,
checks
,
good
,
bad_build
,
bad_runtime
,
grad
,
mode
,
grad_rtol
,
eps
,
skip
class
Checker
(
unittest
.
TestCase
):
class
Checker
(
unittest
.
TestCase
):
...
@@ -78,8 +80,11 @@ def makeTester(name, op, expected, checks = {}, good = {}, bad_build = {}, bad_r
...
@@ -78,8 +80,11 @@ def makeTester(name, op, expected, checks = {}, good = {}, bad_build = {}, bad_r
bad_runtime
=
_bad_runtime
bad_runtime
=
_bad_runtime
grad
=
_grad
grad
=
_grad
mode
=
_mode
mode
=
_mode
skip
=
skip_
def
test_good
(
self
):
def
test_good
(
self
):
if
skip
:
raise
SkipTest
(
skip
)
for
testname
,
inputs
in
self
.
good
.
items
():
for
testname
,
inputs
in
self
.
good
.
items
():
inputs
=
[
copy
(
input
)
for
input
in
inputs
]
inputs
=
[
copy
(
input
)
for
input
in
inputs
]
inputrs
=
[
value
(
input
)
for
input
in
inputs
]
inputrs
=
[
value
(
input
)
for
input
in
inputs
]
...
@@ -138,6 +143,8 @@ def makeTester(name, op, expected, checks = {}, good = {}, bad_build = {}, bad_r
...
@@ -138,6 +143,8 @@ def makeTester(name, op, expected, checks = {}, good = {}, bad_build = {}, bad_r
%
(
self
.
op
,
testname
,
description
,
inputs
,
variables
))
%
(
self
.
op
,
testname
,
description
,
inputs
,
variables
))
def
test_bad_build
(
self
):
def
test_bad_build
(
self
):
if
skip
:
raise
SkipTest
(
skip
)
for
testname
,
inputs
in
self
.
bad_build
.
items
():
for
testname
,
inputs
in
self
.
bad_build
.
items
():
inputs
=
[
copy
(
input
)
for
input
in
inputs
]
inputs
=
[
copy
(
input
)
for
input
in
inputs
]
inputrs
=
[
value
(
input
)
for
input
in
inputs
]
inputrs
=
[
value
(
input
)
for
input
in
inputs
]
...
@@ -149,6 +156,8 @@ def makeTester(name, op, expected, checks = {}, good = {}, bad_build = {}, bad_r
...
@@ -149,6 +156,8 @@ def makeTester(name, op, expected, checks = {}, good = {}, bad_build = {}, bad_r
%
(
self
.
op
,
testname
,
node
,
inputs
))
%
(
self
.
op
,
testname
,
node
,
inputs
))
def
test_bad_runtime
(
self
):
def
test_bad_runtime
(
self
):
if
skip
:
raise
SkipTest
(
skip
)
for
testname
,
inputs
in
self
.
bad_runtime
.
items
():
for
testname
,
inputs
in
self
.
bad_runtime
.
items
():
inputs
=
[
copy
(
input
)
for
input
in
inputs
]
inputs
=
[
copy
(
input
)
for
input
in
inputs
]
inputrs
=
[
value
(
input
)
for
input
in
inputs
]
inputrs
=
[
value
(
input
)
for
input
in
inputs
]
...
@@ -179,6 +188,8 @@ def makeTester(name, op, expected, checks = {}, good = {}, bad_build = {}, bad_r
...
@@ -179,6 +188,8 @@ def makeTester(name, op, expected, checks = {}, good = {}, bad_build = {}, bad_r
%
(
self
.
op
,
testname
,
inputs
))
%
(
self
.
op
,
testname
,
inputs
))
def
test_grad
(
self
):
def
test_grad
(
self
):
if
skip
:
raise
SkipTest
(
skip
)
for
testname
,
inputs
in
self
.
grad
.
items
():
for
testname
,
inputs
in
self
.
grad
.
items
():
inputs
=
[
copy
(
input
)
for
input
in
inputs
]
inputs
=
[
copy
(
input
)
for
input
in
inputs
]
inputrs
=
[
value
(
input
)
for
input
in
inputs
]
inputrs
=
[
value
(
input
)
for
input
in
inputs
]
...
@@ -722,39 +733,47 @@ del _good_broadcast_unary_normal_no_int_no_complex['integers']
...
@@ -722,39 +733,47 @@ del _good_broadcast_unary_normal_no_int_no_complex['integers']
_good_broadcast_unary_normal_no_int
=
_good_broadcast_unary_normal
.
copy
()
_good_broadcast_unary_normal_no_int
=
_good_broadcast_unary_normal
.
copy
()
del
_good_broadcast_unary_normal_no_int
[
'integers'
]
del
_good_broadcast_unary_normal_no_int
[
'integers'
]
# We can't test it if scipy is not installed!
# Precomputing the result is brittle(it have been broken!)
# As if we do any modification to random number here,
# The input random number will change and the output!
if
imported_scipy_special
:
if
imported_scipy_special
:
# We can't test it if scipy is not installed!
expected_erf
=
scipy
.
special
.
erf
# Precomputing the result is brittle(it have been broken!)
expected_erfc
=
scipy
.
special
.
erfc
# As if we do any modification to random number here,
else
:
# The input random number will change and the output!
expected_erf
=
[]
expected
=
scipy
.
special
.
erf
expected
_erfc
=
[]
ErfTester
=
makeBroadcastTester
(
op
=
erf
,
ErfTester
=
makeBroadcastTester
(
op
=
erf
,
expected
=
scipy
.
special
.
erf
,
expected
=
expected_
erf
,
good
=
_good_broadcast_unary_normal
,
good
=
_good_broadcast_unary_normal
,
grad
=
_grad_broadcast_unary_normal
,
grad
=
_grad_broadcast_unary_normal
,
eps
=
2e-10
,
eps
=
2e-10
,
mode
=
mode_no_scipy
)
mode
=
mode_no_scipy
,
ErfInplaceTester
=
makeBroadcastTester
(
op
=
inplace
.
erf_inplace
,
skip
=
False
if
imported_scipy_special
else
"scipy not present"
)
expected
=
scipy
.
special
.
erf
,
ErfInplaceTester
=
makeBroadcastTester
(
op
=
inplace
.
erf_inplace
,
expected
=
expected_erf
,
good
=
_good_broadcast_unary_normal_no_int
,
good
=
_good_broadcast_unary_normal_no_int
,
grad
=
_grad_broadcast_unary_normal
,
grad
=
_grad_broadcast_unary_normal
,
mode
=
mode_no_scipy
,
mode
=
mode_no_scipy
,
eps
=
2e-10
,
eps
=
2e-10
,
inplace
=
True
)
inplace
=
True
,
skip
=
False
if
imported_scipy_special
else
"scipy not present"
)
ErfcTester
=
makeBroadcastTester
(
op
=
erfc
,
ErfcTester
=
makeBroadcastTester
(
op
=
erfc
,
expected
=
scipy
.
special
.
erfc
,
expected
=
expected_
erfc
,
good
=
_good_broadcast_unary_normal_no_int_no_complex
,
good
=
_good_broadcast_unary_normal_no_int_no_complex
,
grad
=
_grad_broadcast_unary_normal
,
grad
=
_grad_broadcast_unary_normal
,
eps
=
2e-10
,
eps
=
2e-10
,
mode
=
mode_no_scipy
)
mode
=
mode_no_scipy
,
ErfcInplaceTester
=
makeBroadcastTester
(
op
=
inplace
.
erfc_inplace
,
skip
=
False
if
imported_scipy_special
else
"scipy not present"
)
expected
=
scipy
.
special
.
erfc
,
ErfcInplaceTester
=
makeBroadcastTester
(
op
=
inplace
.
erfc_inplace
,
expected
=
expected_erfc
,
good
=
_good_broadcast_unary_normal_no_int_no_complex
,
good
=
_good_broadcast_unary_normal_no_int_no_complex
,
grad
=
_grad_broadcast_unary_normal
,
grad
=
_grad_broadcast_unary_normal
,
eps
=
2e-10
,
eps
=
2e-10
,
mode
=
mode_no_scipy
,
mode
=
mode_no_scipy
,
inplace
=
True
)
inplace
=
True
,
skip
=
False
if
imported_scipy_special
else
"scipy not present"
)
DotTester
=
makeTester
(
name
=
'DotTester'
,
DotTester
=
makeTester
(
name
=
'DotTester'
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论