Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
964dcf94
提交
964dcf94
authored
7月 09, 2013
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename var for clarity
上级
121bea82
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
21 行增加
和
21 行删除
+21
-21
unittest_tools.py
theano/tests/unittest_tools.py
+21
-21
没有找到文件。
theano/tests/unittest_tools.py
浏览文件 @
964dcf94
...
@@ -242,7 +242,7 @@ class InferShapeTester(unittest.TestCase):
...
@@ -242,7 +242,7 @@ class InferShapeTester(unittest.TestCase):
assert
numpy
.
all
(
out
.
shape
==
shape
)
assert
numpy
.
all
(
out
.
shape
==
shape
)
def
str_diagnostic
(
val1
,
val2
,
rtol
,
atol
):
def
str_diagnostic
(
expected
,
value
,
rtol
,
atol
):
"""Return a pretty multiline string representating the cause
"""Return a pretty multiline string representating the cause
of the exception"""
of the exception"""
sio
=
StringIO
()
sio
=
StringIO
()
...
@@ -251,13 +251,13 @@ def str_diagnostic(val1, val2, rtol, atol):
...
@@ -251,13 +251,13 @@ def str_diagnostic(val1, val2, rtol, atol):
ssio
=
StringIO
()
ssio
=
StringIO
()
print
>>
ssio
,
" : shape, dtype, strides, min, max, n_inf, n_nan:"
print
>>
ssio
,
" : shape, dtype, strides, min, max, n_inf, n_nan:"
print
>>
ssio
,
" Expected :"
,
print
>>
ssio
,
" Expected :"
,
print
>>
ssio
,
val1
.
shape
,
print
>>
ssio
,
expected
.
shape
,
print
>>
ssio
,
val1
.
dtype
,
print
>>
ssio
,
expected
.
dtype
,
print
>>
ssio
,
val1
.
strides
,
print
>>
ssio
,
expected
.
strides
,
print
>>
ssio
,
val1
.
min
(),
print
>>
ssio
,
expected
.
min
(),
print
>>
ssio
,
val1
.
max
(),
print
>>
ssio
,
expected
.
max
(),
print
>>
ssio
,
numpy
.
isinf
(
val1
)
.
sum
(),
print
>>
ssio
,
numpy
.
isinf
(
expected
)
.
sum
(),
print
>>
ssio
,
numpy
.
isnan
(
val1
)
.
sum
(),
print
>>
ssio
,
numpy
.
isnan
(
expected
)
.
sum
(),
# only if all succeeds to we add anything to sio
# only if all succeeds to we add anything to sio
print
>>
sio
,
ssio
.
getvalue
()
print
>>
sio
,
ssio
.
getvalue
()
except
Exception
:
except
Exception
:
...
@@ -265,24 +265,24 @@ def str_diagnostic(val1, val2, rtol, atol):
...
@@ -265,24 +265,24 @@ def str_diagnostic(val1, val2, rtol, atol):
try
:
try
:
ssio
=
StringIO
()
ssio
=
StringIO
()
print
>>
ssio
,
" Value :"
,
print
>>
ssio
,
" Value :"
,
print
>>
ssio
,
val
2
.
shape
,
print
>>
ssio
,
val
ue
.
shape
,
print
>>
ssio
,
val
2
.
dtype
,
print
>>
ssio
,
val
ue
.
dtype
,
print
>>
ssio
,
val
2
.
strides
,
print
>>
ssio
,
val
ue
.
strides
,
print
>>
ssio
,
val
2
.
min
(),
print
>>
ssio
,
val
ue
.
min
(),
print
>>
ssio
,
val
2
.
max
(),
print
>>
ssio
,
val
ue
.
max
(),
print
>>
ssio
,
numpy
.
isinf
(
val
2
)
.
sum
(),
print
>>
ssio
,
numpy
.
isinf
(
val
ue
)
.
sum
(),
print
>>
ssio
,
numpy
.
isnan
(
val
2
)
.
sum
(),
print
>>
ssio
,
numpy
.
isnan
(
val
ue
)
.
sum
(),
# only if all succeeds to we add anything to sio
# only if all succeeds to we add anything to sio
print
>>
sio
,
ssio
.
getvalue
()
print
>>
sio
,
ssio
.
getvalue
()
except
Exception
:
except
Exception
:
pass
pass
print
>>
sio
,
"
val1 :"
,
val1
print
>>
sio
,
"
expected :"
,
expected
print
>>
sio
,
" val
2 :"
,
val2
print
>>
sio
,
" val
ue :"
,
value
try
:
try
:
ov
=
numpy
.
asarray
(
val1
)
ov
=
numpy
.
asarray
(
expected
)
nv
=
numpy
.
asarray
(
val
2
)
nv
=
numpy
.
asarray
(
val
ue
)
ssio
=
StringIO
()
ssio
=
StringIO
()
absdiff
=
numpy
.
absolute
(
nv
-
ov
)
absdiff
=
numpy
.
absolute
(
nv
-
ov
)
print
>>
ssio
,
" Max Abs Diff: "
,
numpy
.
max
(
absdiff
)
print
>>
ssio
,
" Max Abs Diff: "
,
numpy
.
max
(
absdiff
)
...
@@ -301,8 +301,8 @@ def str_diagnostic(val1, val2, rtol, atol):
...
@@ -301,8 +301,8 @@ def str_diagnostic(val1, val2, rtol, atol):
pass
pass
#Use the same formula as in _allclose to find the tolerance used
#Use the same formula as in _allclose to find the tolerance used
narrow
=
'float32'
,
'complex64'
narrow
=
'float32'
,
'complex64'
if
((
str
(
val1
.
dtype
)
in
narrow
)
or
if
((
str
(
expected
.
dtype
)
in
narrow
)
or
(
str
(
val
2
.
dtype
)
in
narrow
)):
(
str
(
val
ue
.
dtype
)
in
narrow
)):
atol_
=
T
.
basic
.
float32_atol
atol_
=
T
.
basic
.
float32_atol
rtol_
=
T
.
basic
.
float32_rtol
rtol_
=
T
.
basic
.
float32_rtol
else
:
else
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论