Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e697280a
提交
e697280a
authored
7月 22, 2013
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pep8
上级
ac7c37a3
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
14 行增加
和
12 行删除
+14
-12
unittest_tools.py
theano/tests/unittest_tools.py
+14
-12
没有找到文件。
theano/tests/unittest_tools.py
浏览文件 @
e697280a
...
@@ -30,10 +30,10 @@ def good_seed_param(seed):
...
@@ -30,10 +30,10 @@ def good_seed_param(seed):
return
True
return
True
AddConfigVar
(
'unittests.rseed'
,
AddConfigVar
(
'unittests.rseed'
,
"Seed to use for randomized unit tests. "
"Seed to use for randomized unit tests. "
"Special value 'random' means using a seed of None."
,
"Special value 'random' means using a seed of None."
,
StrParam
(
666
,
is_valid
=
good_seed_param
),
StrParam
(
666
,
is_valid
=
good_seed_param
),
in_c_key
=
False
)
in_c_key
=
False
)
def
fetch_seed
(
pseed
=
None
):
def
fetch_seed
(
pseed
=
None
):
...
@@ -41,15 +41,15 @@ def fetch_seed(pseed=None):
...
@@ -41,15 +41,15 @@ def fetch_seed(pseed=None):
Returns the seed to use for running the unit tests.
Returns the seed to use for running the unit tests.
If an explicit seed is given, it will be used for seeding numpy's rng.
If an explicit seed is given, it will be used for seeding numpy's rng.
If not, it will use config.unittest.rseed (its default value is 666).
If not, it will use config.unittest.rseed (its default value is 666).
If config.unittest.rseed is set to "random", it will seed the rng with
None,
If config.unittest.rseed is set to "random", it will seed the rng with
which is equivalent to seeding with a random seed.
None,
which is equivalent to seeding with a random seed.
Useful for seeding RandomState objects.
Useful for seeding RandomState objects.
>>> rng = numpy.random.RandomState(unittest_tools.fetch_seed())
>>> rng = numpy.random.RandomState(unittest_tools.fetch_seed())
"""
"""
seed
=
pseed
or
config
.
unittests
.
rseed
seed
=
pseed
or
config
.
unittests
.
rseed
if
seed
==
'random'
:
if
seed
==
'random'
:
seed
=
None
seed
=
None
try
:
try
:
...
@@ -58,8 +58,8 @@ def fetch_seed(pseed=None):
...
@@ -58,8 +58,8 @@ def fetch_seed(pseed=None):
else
:
else
:
seed
=
None
seed
=
None
except
ValueError
:
except
ValueError
:
print
>>
sys
.
stderr
,
'Error: config.unittests.rseed contains '
\
print
>>
sys
.
stderr
,
(
'Error: config.unittests.rseed contains '
'invalid seed, using None instead'
'invalid seed, using None instead'
)
seed
=
None
seed
=
None
return
seed
return
seed
...
@@ -72,7 +72,7 @@ def seed_rng(pseed=None):
...
@@ -72,7 +72,7 @@ def seed_rng(pseed=None):
"""
"""
seed
=
fetch_seed
(
pseed
)
seed
=
fetch_seed
(
pseed
)
if
pseed
and
pseed
!=
seed
:
if
pseed
and
pseed
!=
seed
:
print
>>
sys
.
stderr
,
'Warning: using seed given by config.unittests.rseed=
%
i'
\
print
>>
sys
.
stderr
,
'Warning: using seed given by config.unittests.rseed=
%
i'
\
'instead of seed
%
i given as parameter'
%
(
seed
,
pseed
)
'instead of seed
%
i given as parameter'
%
(
seed
,
pseed
)
numpy
.
random
.
seed
(
seed
)
numpy
.
random
.
seed
(
seed
)
...
@@ -155,7 +155,8 @@ class T_OpContractMixin(object):
...
@@ -155,7 +155,8 @@ class T_OpContractMixin(object):
assert
op_i
==
self
.
clone
(
op_i
)
assert
op_i
==
self
.
clone
(
op_i
)
assert
op_i
!=
self
.
other_op
assert
op_i
!=
self
.
other_op
for
j
,
op_j
in
enumerate
(
self
.
ops
):
for
j
,
op_j
in
enumerate
(
self
.
ops
):
if
i
==
j
:
continue
if
i
==
j
:
continue
assert
op_i
!=
op_j
assert
op_i
!=
op_j
def
test_hash
(
self
):
def
test_hash
(
self
):
...
@@ -167,7 +168,8 @@ class T_OpContractMixin(object):
...
@@ -167,7 +168,8 @@ class T_OpContractMixin(object):
assert
h_i
==
hash
(
self
.
clone
(
op_i
))
assert
h_i
==
hash
(
self
.
clone
(
op_i
))
assert
h_i
!=
hash
(
self
.
other_op
)
assert
h_i
!=
hash
(
self
.
other_op
)
for
j
,
op_j
in
enumerate
(
self
.
ops
):
for
j
,
op_j
in
enumerate
(
self
.
ops
):
if
i
==
j
:
continue
if
i
==
j
:
continue
assert
op_i
!=
hash
(
op_j
)
assert
op_i
!=
hash
(
op_j
)
def
test_name
(
self
):
def
test_name
(
self
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论