Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
fb03fdcf
提交
fb03fdcf
authored
5月 20, 2014
作者:
Hengjean
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactored sparse matrices comparison tests
上级
21b69c83
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
32 行增加
和
221 行删除
+32
-221
test_basic.py
theano/sparse/tests/test_basic.py
+32
-221
没有找到文件。
theano/sparse/tests/test_basic.py
浏览文件 @
fb03fdcf
...
@@ -656,6 +656,12 @@ class test_comparison(unittest.TestCase):
...
@@ -656,6 +656,12 @@ class test_comparison(unittest.TestCase):
return
numpy
.
asarray
(
numpy
.
random
.
rand
(
*
shape
)
*
(
max
-
min
)
+
min
,
return
numpy
.
asarray
(
numpy
.
random
.
rand
(
*
shape
)
*
(
max
-
min
)
+
min
,
dtype
=
config
.
floatX
)
dtype
=
config
.
floatX
)
tests
=
[
lambda
x
,
y
:
x
>
y
,
lambda
x
,
y
:
x
<
y
,
lambda
x
,
y
:
x
>=
y
,
lambda
x
,
y
:
x
<=
y
]
testsDic
=
{
gt
:
lambda
x
,
y
:
x
>
y
,
lt
:
lambda
x
,
y
:
x
<
y
,
ge
:
lambda
x
,
y
:
x
>=
y
,
le
:
lambda
x
,
y
:
x
<=
y
}
def
__generalized_ss_test
(
self
,
theanop
,
symbolicType
,
testOp
,
scipyType
):
def
__generalized_ss_test
(
self
,
theanop
,
symbolicType
,
testOp
,
scipyType
):
scipy_ver
=
[
int
(
n
)
for
n
in
scipy
.
__version__
.
split
(
'.'
)[:
2
]]
scipy_ver
=
[
int
(
n
)
for
n
in
scipy
.
__version__
.
split
(
'.'
)[:
2
]]
...
@@ -713,233 +719,41 @@ class test_comparison(unittest.TestCase):
...
@@ -713,233 +719,41 @@ class test_comparison(unittest.TestCase):
self
.
assertTrue
(
numpy
.
array_equal
(
f
(
m2
,
m1
)
.
data
,
testOp
(
m2
,
m1
)
.
data
))
self
.
assertTrue
(
numpy
.
array_equal
(
f
(
m2
,
m1
)
.
data
,
testOp
(
m2
,
m1
)
.
data
))
def
test_equalss_csr
(
self
):
def
test_ss_csr_comparison
(
self
):
self
.
__generalized_ss_test
(
eq
,
sparse
.
csr_matrix
,
lambda
x
,
y
:
x
==
y
,
sp
.
csr_matrix
)
def
test_equalss_csc
(
self
):
self
.
__generalized_ss_test
(
eq
,
sparse
.
csc_matrix
,
lambda
x
,
y
:
x
==
y
,
sp
.
csc_matrix
)
def
test_not_equalss_csr
(
self
):
self
.
__generalized_ss_test
(
neq
,
sparse
.
csr_matrix
,
lambda
x
,
y
:
x
!=
y
,
sp
.
csr_matrix
)
def
test_not_equalss_csc
(
self
):
self
.
__generalized_ss_test
(
neq
,
sparse
.
csc_matrix
,
lambda
x
,
y
:
x
!=
y
,
sp
.
csc_matrix
)
def
test_less_equalss_csr
(
self
):
opT
=
lambda
x
,
y
:
x
<=
y
self
.
__generalized_ss_test
(
le
,
sparse
.
csr_matrix
,
opT
,
sp
.
csr_matrix
)
def
test_less_equalss_csc
(
self
):
opT
=
lambda
x
,
y
:
x
<=
y
self
.
__generalized_ss_test
(
le
,
sparse
.
csc_matrix
,
opT
,
sp
.
csc_matrix
)
def
test_less_thanss_csr
(
self
):
opT
=
lambda
x
,
y
:
x
<
y
self
.
__generalized_ss_test
(
opT
,
sparse
.
csr_matrix
,
opT
,
sp
.
csr_matrix
)
def
test_less_thanss_csc
(
self
):
opT
=
lambda
x
,
y
:
x
<
y
self
.
__generalized_ss_test
(
opT
,
sparse
.
csc_matrix
,
opT
,
sp
.
csc_matrix
)
def
test_greater_equalss_csr
(
self
):
opT
=
lambda
x
,
y
:
x
>=
y
self
.
__generalized_ss_test
(
opT
,
sparse
.
csr_matrix
,
opT
,
sp
.
csr_matrix
)
def
test_greater_equalss_csc
(
self
):
opT
=
lambda
x
,
y
:
x
>=
y
self
.
__generalized_ss_test
(
opT
,
sparse
.
csc_matrix
,
opT
,
sp
.
csc_matrix
)
def
test_greater_thanss_csr
(
self
):
opT
=
lambda
x
,
y
:
x
>
y
self
.
__generalized_ss_test
(
opT
,
sparse
.
csr_matrix
,
opT
,
sp
.
csr_matrix
)
def
test_greater_thanss_csc
(
self
):
opT
=
lambda
x
,
y
:
x
>
y
self
.
__generalized_ss_test
(
opT
,
sparse
.
csc_matrix
,
opT
,
sp
.
csc_matrix
)
def
test_equalsd_csr
(
self
):
self
.
__generalized_sd_test
(
eq
,
sparse
.
csr_matrix
,
lambda
x
,
y
:
x
==
y
,
sp
.
csr_matrix
)
def
test_equalsd_csc
(
self
):
self
.
__generalized_sd_test
(
eq
,
sparse
.
csc_matrix
,
lambda
x
,
y
:
x
==
y
,
sp
.
csc_matrix
)
def
test_not_equalsd_csr
(
self
):
self
.
__generalized_sd_test
(
neq
,
sparse
.
csr_matrix
,
lambda
x
,
y
:
x
!=
y
,
sp
.
csr_matrix
)
def
test_not_equalsd_csc
(
self
):
self
.
__generalized_sd_test
(
neq
,
sparse
.
csc_matrix
,
lambda
x
,
y
:
x
!=
y
,
sp
.
csc_matrix
)
def
test_less_equalsd_csr
(
self
):
opT
=
lambda
x
,
y
:
x
<=
y
self
.
__generalized_sd_test
(
le
,
sparse
.
csr_matrix
,
opT
,
sp
.
csr_matrix
)
def
test_less_equalsd_csc
(
self
):
for
op
in
self
.
tests
:
self
.
__generalized_ss_test
(
op
,
sparse
.
csr_matrix
,
op
,
sp
.
csr_matrix
)
opT
=
lambda
x
,
y
:
x
<=
y
def
test_ss_csc_comparison
(
self
):
self
.
__generalized_sd_test
(
le
,
sparse
.
csc_matrix
,
for
op
in
self
.
tests
:
opT
,
sp
.
csc_matrix
)
self
.
__generalized_ss_test
(
op
,
sparse
.
csc_matrix
,
op
,
sp
.
csc_matrix
)
def
test_
less_thansd_csr
(
self
):
def
test_
sd_csr_comparison
(
self
):
opT
=
lambda
x
,
y
:
x
<
y
for
op
in
self
.
tests
:
self
.
__generalized_sd_test
(
op
,
sparse
.
csr_matrix
,
op
,
sp
.
csr_matrix
)
self
.
__generalized_sd_test
(
opT
,
sparse
.
csr_matrix
,
def
test_sd_csc_comparison
(
self
):
opT
,
sp
.
csr_matrix
)
def
test_less_thansd_csc
(
self
):
for
op
in
self
.
tests
:
self
.
__generalized_sd_test
(
op
,
sparse
.
csc_matrix
,
op
,
sp
.
csc_matrix
)
opT
=
lambda
x
,
y
:
x
<
y
def
test_ds_csc_comparison
(
self
):
self
.
__generalized_sd_test
(
opT
,
sparse
.
csc_matrix
,
for
op
in
self
.
testsDic
:
opT
,
sp
.
csc_matrix
)
self
.
__generalized_ds_test
(
op
,
sparse
.
csc_matrix
,
self
.
testsDic
[
op
],
sp
.
csc_matrix
)
def
test_
greater_equalsd_csr
(
self
):
def
test_
ds_csr_comparison
(
self
):
opT
=
lambda
x
,
y
:
x
>=
y
for
op
in
self
.
testsDic
:
self
.
__generalized_ds_test
(
op
,
sparse
.
csr_matrix
,
self
.
__generalized_sd_test
(
opT
,
sparse
.
csr_matrix
,
self
.
testsDic
[
op
],
sp
.
csr_matrix
)
opT
,
sp
.
csr_matrix
)
def
test_greater_equalsd_csc
(
self
):
opT
=
lambda
x
,
y
:
x
>=
y
self
.
__generalized_sd_test
(
opT
,
sparse
.
csc_matrix
,
opT
,
sp
.
csc_matrix
)
def
test_greater_thansd_csr
(
self
):
opT
=
lambda
x
,
y
:
x
>
y
self
.
__generalized_sd_test
(
opT
,
sparse
.
csr_matrix
,
opT
,
sp
.
csr_matrix
)
def
test_greater_thansd_csc
(
self
):
opT
=
lambda
x
,
y
:
x
>
y
self
.
__generalized_sd_test
(
opT
,
sparse
.
csc_matrix
,
opT
,
sp
.
csc_matrix
)
def
test_equalds_csr
(
self
):
self
.
__generalized_ds_test
(
eq
,
sparse
.
csr_matrix
,
lambda
x
,
y
:
x
==
y
,
sp
.
csr_matrix
)
def
test_equalds_csc
(
self
):
self
.
__generalized_ds_test
(
eq
,
sparse
.
csc_matrix
,
lambda
x
,
y
:
x
==
y
,
sp
.
csc_matrix
)
def
test_not_equalds_csr
(
self
):
self
.
__generalized_ds_test
(
neq
,
sparse
.
csr_matrix
,
lambda
x
,
y
:
x
!=
y
,
sp
.
csr_matrix
)
def
test_not_equalds_csc
(
self
):
self
.
__generalized_ds_test
(
neq
,
sparse
.
csc_matrix
,
lambda
x
,
y
:
x
!=
y
,
sp
.
csc_matrix
)
def
test_less_equalds_csr
(
self
):
opT
=
lambda
x
,
y
:
x
<=
y
self
.
__generalized_ds_test
(
le
,
sparse
.
csr_matrix
,
opT
,
sp
.
csr_matrix
)
def
test_less_equalds_csc
(
self
):
opT
=
lambda
x
,
y
:
x
<=
y
self
.
__generalized_ds_test
(
le
,
sparse
.
csc_matrix
,
opT
,
sp
.
csc_matrix
)
def
test_less_thands_csr
(
self
):
opT
=
lambda
x
,
y
:
x
<
y
self
.
__generalized_ds_test
(
lt
,
sparse
.
csr_matrix
,
opT
,
sp
.
csr_matrix
)
def
test_less_thands_csc
(
self
):
opT
=
lambda
x
,
y
:
x
<
y
self
.
__generalized_ds_test
(
lt
,
sparse
.
csc_matrix
,
opT
,
sp
.
csc_matrix
)
def
test_greater_equalds_csr
(
self
):
opT
=
lambda
x
,
y
:
x
>=
y
self
.
__generalized_ds_test
(
ge
,
sparse
.
csr_matrix
,
opT
,
sp
.
csr_matrix
)
def
test_greater_equalds_csc
(
self
):
opT
=
lambda
x
,
y
:
x
>=
y
self
.
__generalized_ds_test
(
ge
,
sparse
.
csc_matrix
,
opT
,
sp
.
csc_matrix
)
def
test_greater_thands_csr
(
self
):
opT
=
lambda
x
,
y
:
x
>
y
self
.
__generalized_ds_test
(
gt
,
sparse
.
csr_matrix
,
opT
,
sp
.
csr_matrix
)
def
test_greater_thands_csc
(
self
):
opT
=
lambda
x
,
y
:
x
>
y
self
.
__generalized_ds_test
(
gt
,
sparse
.
csc_matrix
,
opT
,
sp
.
csc_matrix
)
def
test_equality_case
(
self
):
def
test_equality_case
(
self
):
"""
"""
...
@@ -958,16 +772,13 @@ class test_comparison(unittest.TestCase):
...
@@ -958,16 +772,13 @@ class test_comparison(unittest.TestCase):
m1
=
sp
.
csc_matrix
((
2
,
2
),
dtype
=
theano
.
config
.
floatX
)
m1
=
sp
.
csc_matrix
((
2
,
2
),
dtype
=
theano
.
config
.
floatX
)
m2
=
numpy
.
asarray
([[
0
,
0
],
[
0
,
0
]])
m2
=
numpy
.
asarray
([[
0
,
0
],
[
0
,
0
]])
test
=
{
gt
:
lambda
x
,
y
:
x
>
y
,
lt
:
lambda
x
,
y
:
x
<
y
,
for
func
in
self
.
testsDic
:
ge
:
lambda
x
,
y
:
x
>=
y
,
le
:
lambda
x
,
y
:
x
<=
y
}
for
func
in
test
:
op
=
func
(
y
,
x
)
op
=
func
(
y
,
x
)
f
=
theano
.
function
([
y
,
x
],
op
)
f
=
theano
.
function
([
y
,
x
],
op
)
self
.
assertTrue
(
numpy
.
array_equal
(
f
(
m2
,
m1
),
self
.
assertTrue
(
numpy
.
array_equal
(
f
(
m2
,
m1
),
test
[
func
](
m2
,
m1
)))
self
.
testsDic
[
func
](
m2
,
m1
)))
class
T_conversion
(
unittest
.
TestCase
):
class
T_conversion
(
unittest
.
TestCase
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论