Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
53ca7d6f
提交
53ca7d6f
authored
12月 12, 2008
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
-refactored the test_module to be a class of unittest so that we can use assertRaise
-started writing missing test.
上级
55c5a737
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
102 行增加
和
67 行删除
+102
-67
test_module.py
theano/compile/tests/test_module.py
+102
-67
没有找到文件。
theano/compile/tests/test_module.py
浏览文件 @
53ca7d6f
import
unittest
from
theano.compile.module
import
*
from
theano.compile.module
import
*
import
theano.tensor
as
T
import
theano.tensor
as
T
import
sys
import
sys
def
test_whats_up_with_submembers
():
class
T_test_module
(
unittest
.
TestCase
):
class
Blah
(
FancyModule
):
def
__init__
(
self
,
stepsize
):
super
(
Blah
,
self
)
.
__init__
()
self
.
stepsize
=
Member
(
T
.
value
(
stepsize
))
x
=
T
.
dscalar
()
self
.
step
=
Method
([
x
],
x
-
self
.
stepsize
)
B
=
Blah
(
0.0
)
b
=
B
.
make
(
mode
=
'FAST_RUN'
)
b
.
step
(
1.0
)
print
b
.
stepsize
assert
b
.
stepsize
==
0.0
def
test_no_shared_members
():
"""Test that a Result cannot become a Member of two connected Modules"""
print
>>
sys
.
stderr
,
"WARNING MODULE TEST NOT IMPLEMENTED"
def
test_members_in_list_or_dict
():
def
test_whats_up_with_submembers
(
self
):
"""Test that a Member which is only included via a list or dictionary is still treated as if it
class
Blah
(
FancyModule
):
were a toplevel attribute"""
def
__init__
(
self
,
stepsize
):
print
>>
sys
.
stderr
,
"WARNING MODULE TEST NOT IMPLEMENTED"
super
(
Blah
,
self
)
.
__init__
(
self
)
self
.
stepsize
=
Member
(
T
.
value
(
stepsize
))
def
test_method_in_list_or_dict
():
x
=
T
.
dscalar
()
"""Test that a Method which is only included via a list or dictionary is still treated as if it
were a toplevel attribute"""
self
.
step
=
Method
([
x
],
x
-
self
.
stepsize
)
print
>>
sys
.
stderr
,
"WARNING MODULE TEST NOT IMPLEMENTED"
B
=
Blah
(
0.0
)
def
test_shared_members
():
b
=
B
.
make
(
mode
=
'FAST_RUN'
)
"""Test that under a variety of tricky conditions, the shared-ness of Results and Members
b
.
step
(
1.0
)
is respected."""
print
b
.
stepsize
print
>>
sys
.
stderr
,
"WARNING MODULE TEST NOT IMPLEMENTED"
assert
b
.
stepsize
==
0.0
def
test_no_shared_members
(
self
):
"""Test that a Result cannot become a Member of two connected Modules
FRED: What is the purpose of this test? Why we should not be able to do it?
Right now it seem to work when it should not.
"""
x
=
T
.
dscalar
()
y
=
Member
(
T
.
dscalar
())
m1
=
Module
()
m2
=
Module
()
m1
.
x
=
x
m2
.
x
=
x
m1
.
y
=
y
m2
.
y
=
y
m2
.
m1
=
m1
m2
.
make
()
m1
.
make
()
print
>>
sys
.
stderr
,
"WARNING MODULE TEST NOT IMPLEMENTED1"
def
test_members_in_list_or_dict
(
self
):
"""Test that a Member which is only included via a list or dictionary is still treated as if it
were a toplevel attribute
Fred: toplevel attribute? toplevel member?
"""
x
=
T
.
dscalar
()
y
=
Member
(
T
.
dscalar
())
m1
=
Module
()
m1
.
lx
=
[
x
]
m1
.
ly
=
[
y
]
m1
.
dx
=
{
"x"
:
x
}
m1
.
dy
=
{
"y"
:
y
}
m1
.
x
=
x
m1
.
y
=
y
inst
=
m1
.
make
()
print
m1
print
inst
assert
inst
.
lx
assert
inst
.
ly
self
.
assertRaises
(
AttributeError
,
inst
.
__getattr__
,
x
)
self
.
assertRaises
(
AttributeError
,
inst
.
__getattr__
,
y
)
#FRED why this raise an exception?
print
>>
sys
.
stderr
,
"WARNING MODULE TEST NOT IMPLEMENTED2"
def
test_method_in_list_or_dict
(
self
):
"""Test that a Method which is only included via a list or dictionary is still treated as if it
were a toplevel attribute"""
print
>>
sys
.
stderr
,
"WARNING MODULE TEST NOT IMPLEMENTED"
def
test_shared_members
(
self
):
"""Test that under a variety of tricky conditions, the shared-ness of Results and Members
is respected."""
print
>>
sys
.
stderr
,
"WARNING MODULE TEST NOT IMPLEMENTED"
#put them in subModules, sub-sub-Modules, shared between a list and a dict, shared between
#put them in subModules, sub-sub-Modules, shared between a list and a dict, shared between
#a list and a submodule with a dictionary, etc...
#a list and a submodule with a dictionary, etc...
def
test_shared_members_N
(
):
def
test_shared_members_N
(
self
):
"""Test that Members can be shared an arbitrary number of times between many submodules and
"""Test that Members can be shared an arbitrary number of times between many submodules and
internal data structures."""
internal data structures."""
print
>>
sys
.
stderr
,
"WARNING MODULE TEST NOT IMPLEMENTED"
print
>>
sys
.
stderr
,
"WARNING MODULE TEST NOT IMPLEMENTED"
#put them in subModules, sub-sub-Modules, shared between a list and a dict, shared between
#put them in subModules, sub-sub-Modules, shared between a list and a dict, shared between
#a list and a submodule with a dictionary, etc...
#a list and a submodule with a dictionary, etc...
def
test_shared_method
(
):
def
test_shared_method
(
self
):
"""Test that under a variety of tricky conditions, the shared-ness of Results and Methods
"""Test that under a variety of tricky conditions, the shared-ness of Results and Methods
is respected."""
is respected."""
print
>>
sys
.
stderr
,
"WARNING MODULE TEST NOT IMPLEMENTED"
print
>>
sys
.
stderr
,
"WARNING MODULE TEST NOT IMPLEMENTED"
#put them in subModules, sub-sub-Modules, shared between a list and a dict, shared between
#put them in subModules, sub-sub-Modules, shared between a list and a dict, shared between
#a list and a submodule with a dictionary, etc...
#a list and a submodule with a dictionary, etc...
def
test_shared_method_N
(
):
def
test_shared_method_N
(
self
):
"""Test that Methods can be shared an arbitrary number of times between many submodules and
"""Test that Methods can be shared an arbitrary number of times between many submodules and
internal data structures."""
internal data structures."""
#put them in subModules, sub-sub-Modules, shared between a list and a dict, shared between
#put them in subModules, sub-sub-Modules, shared between a list and a dict, shared between
#a list and a submodule with a dictionary, etc...
#a list and a submodule with a dictionary, etc...
print
>>
sys
.
stderr
,
"WARNING MODULE TEST NOT IMPLEMENTED"
print
>>
sys
.
stderr
,
"WARNING MODULE TEST NOT IMPLEMENTED"
def
test_member_method_inputs
(
):
def
test_member_method_inputs
(
self
):
"""Test that module Members can be named as Method inputs, in which case the function will
"""Test that module Members can be named as Method inputs, in which case the function will
*not* use the storage allocated for the Module's version of that Member."""
*not* use the storage allocated for the Module's version of that Member."""
print
>>
sys
.
stderr
,
"WARNING MODULE TEST NOT IMPLEMENTED"
print
>>
sys
.
stderr
,
"WARNING MODULE TEST NOT IMPLEMENTED"
def
test_member_input_flags
(
):
def
test_member_input_flags
(
self
):
"""Test that we can manipulate the mutable, strict, etc. flags (see SymbolicInput) of
"""Test that we can manipulate the mutable, strict, etc. flags (see SymbolicInput) of
Method inputs"""
Method inputs"""
print
>>
sys
.
stderr
,
"WARNING MODULE TEST NOT IMPLEMENTED"
print
>>
sys
.
stderr
,
"WARNING MODULE TEST NOT IMPLEMENTED"
def
test_member_output_flags
(
):
def
test_member_output_flags
(
self
):
"""Test that we can manipulate the output flags (just 'borrow' I think, see SymbolicOutput)
"""Test that we can manipulate the output flags (just 'borrow' I think, see SymbolicOutput)
of Method outputs"""
of Method outputs"""
print
>>
sys
.
stderr
,
"WARNING MODULE TEST NOT IMPLEMENTED"
print
>>
sys
.
stderr
,
"WARNING MODULE TEST NOT IMPLEMENTED"
def
test_sanity_check_mode
(
):
def
test_sanity_check_mode
(
self
):
"""Test that Module.make(
) can take the same list of Modes that function can, so we can
"""Test that Module.make(self
) can take the same list of Modes that function can, so we can
debug modules"""
debug modules"""
print
>>
sys
.
stderr
,
"WARNING MODULE TEST NOT IMPLEMENTED"
print
>>
sys
.
stderr
,
"WARNING MODULE TEST NOT IMPLEMENTED"
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论