Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d5acdc77
提交
d5acdc77
authored
7月 21, 2012
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix docstring and execute all tests when calling the file.
上级
a5a68aaf
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
14 行增加
和
22 行删除
+14
-22
test_raw_random.py
theano/tensor/tests/test_raw_random.py
+14
-22
没有找到文件。
theano/tensor/tests/test_raw_random.py
浏览文件 @
d5acdc77
...
@@ -123,8 +123,8 @@ class T_random_function(utt.InferShapeTester):
...
@@ -123,8 +123,8 @@ class T_random_function(utt.InferShapeTester):
assert
not
numpy
.
allclose
(
val0
,
val1
)
assert
not
numpy
.
allclose
(
val0
,
val1
)
def
test_no_inplace
(
self
):
def
test_no_inplace
(
self
):
"""Test that when not running inplace, the RandomState is
'
"""Test that when not running inplace, the RandomState is
'
not updated"""
not updated"""
rf
=
RandomFunction
(
'uniform'
,
tensor
.
dvector
)
rf
=
RandomFunction
(
'uniform'
,
tensor
.
dvector
)
rng_R
=
random_state_type
()
rng_R
=
random_state_type
()
...
@@ -236,8 +236,8 @@ class T_random_function(utt.InferShapeTester):
...
@@ -236,8 +236,8 @@ class T_random_function(utt.InferShapeTester):
self
.
assertRaises
(
TypeError
,
permutation
,
rng_R
,
size
=
None
,
ndim
=
2
)
self
.
assertRaises
(
TypeError
,
permutation
,
rng_R
,
size
=
None
,
ndim
=
2
)
def
test_random_function_ndim_added
(
self
):
def
test_random_function_ndim_added
(
self
):
"""Test that random_function helper function accepts ndim_added as
'
"""Test that random_function helper function accepts ndim_added as
'
keyword argument"""
keyword argument"""
# If using numpy's uniform distribution, ndim_added should be 0,
# If using numpy's uniform distribution, ndim_added should be 0,
# because the shape provided as argument is the output shape.
# because the shape provided as argument is the output shape.
# Specifying a different ndim_added will change the Op's output ndim,
# Specifying a different ndim_added will change the Op's output ndim,
...
@@ -339,8 +339,8 @@ class T_random_function(utt.InferShapeTester):
...
@@ -339,8 +339,8 @@ class T_random_function(utt.InferShapeTester):
self
.
assertTrue
(
numpy
.
allclose
(
val1
,
numpy_val1
))
self
.
assertTrue
(
numpy
.
allclose
(
val1
,
numpy_val1
))
def
test_binomial
(
self
):
def
test_binomial
(
self
):
"""Test that raw_random.binomial generates the same results
'
"""Test that raw_random.binomial generates the same results
'
as numpy."""
as numpy."""
# Check over two calls to see if the random state is correctly updated.
# Check over two calls to see if the random state is correctly updated.
rng_R
=
random_state_type
()
rng_R
=
random_state_type
()
# Use non-default parameters, and larger dimensions because of
# Use non-default parameters, and larger dimensions because of
...
@@ -391,8 +391,8 @@ class T_random_function(utt.InferShapeTester):
...
@@ -391,8 +391,8 @@ class T_random_function(utt.InferShapeTester):
self
.
assertTrue
(
numpy
.
allclose
(
val1
,
numpy_val1
))
self
.
assertTrue
(
numpy
.
allclose
(
val1
,
numpy_val1
))
def
test_random_integers
(
self
):
def
test_random_integers
(
self
):
"""Test that raw_random.random_integers generates the same
'
"""Test that raw_random.random_integers generates the same
'
results as numpy."""
results as numpy."""
# Check over two calls to see if the random state is correctly updated.
# Check over two calls to see if the random state is correctly updated.
rng_R
=
random_state_type
()
rng_R
=
random_state_type
()
# Use non-default parameters, and larger dimensions because of
# Use non-default parameters, and larger dimensions because of
...
@@ -418,8 +418,8 @@ class T_random_function(utt.InferShapeTester):
...
@@ -418,8 +418,8 @@ class T_random_function(utt.InferShapeTester):
self
.
assertTrue
(
numpy
.
allclose
(
val1
,
numpy_val1
))
self
.
assertTrue
(
numpy
.
allclose
(
val1
,
numpy_val1
))
def
test_permutation_helper
(
self
):
def
test_permutation_helper
(
self
):
"""Test that raw_random.permutation_helper generates the same
'
"""Test that raw_random.permutation_helper generates the same
'
results as numpy,
results as numpy,
and that the 'ndim_added' keyword behaves correctly."""
and that the 'ndim_added' keyword behaves correctly."""
# permutation_helper needs "ndim_added=1", because its output
# permutation_helper needs "ndim_added=1", because its output
# is one dimension more than its "shape" argument (and there's
# is one dimension more than its "shape" argument (and there's
...
@@ -476,8 +476,8 @@ class T_random_function(utt.InferShapeTester):
...
@@ -476,8 +476,8 @@ class T_random_function(utt.InferShapeTester):
self
.
assertRaises
(
ValueError
,
f2
)
self
.
assertRaises
(
ValueError
,
f2
)
def
test_permutation
(
self
):
def
test_permutation
(
self
):
"""Test that raw_random.permutation generates the same
'
"""Test that raw_random.permutation generates the same
'
results as numpy."""
results as numpy."""
rng_R
=
random_state_type
()
rng_R
=
random_state_type
()
post_r
,
out
=
permutation
(
rng_R
,
size
=
(
9
,),
n
=
6
)
post_r
,
out
=
permutation
(
rng_R
,
size
=
(
9
,),
n
=
6
)
print
'OUT NDIM'
,
out
.
ndim
print
'OUT NDIM'
,
out
.
ndim
...
@@ -505,8 +505,8 @@ class T_random_function(utt.InferShapeTester):
...
@@ -505,8 +505,8 @@ class T_random_function(utt.InferShapeTester):
self
.
assertTrue
(
numpy
.
all
(
val1
==
numpy_val1
))
self
.
assertTrue
(
numpy
.
all
(
val1
==
numpy_val1
))
def
test_multinomial
(
self
):
def
test_multinomial
(
self
):
"""Test that raw_random.multinomial generates the same
'
"""Test that raw_random.multinomial generates the same
'
results as numpy."""
results as numpy."""
# Check over two calls to see if the random state is correctly updated.
# Check over two calls to see if the random state is correctly updated.
rng_R
=
random_state_type
()
rng_R
=
random_state_type
()
post_r
,
out
=
multinomial
(
rng_R
,
(
7
,
3
),
6
,
[
0.2
]
*
5
)
post_r
,
out
=
multinomial
(
rng_R
,
(
7
,
3
),
6
,
[
0.2
]
*
5
)
...
@@ -1076,13 +1076,5 @@ class T_random_function(utt.InferShapeTester):
...
@@ -1076,13 +1076,5 @@ class T_random_function(utt.InferShapeTester):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
"""
from
theano.tests
import
main
from
theano.tests
import
main
main
(
"test_raw_random"
)
main
(
"test_raw_random"
)
"""
t
=
T_random_function
(
'setUp'
)
t
.
setUp
()
t
.
test_infer_shape
()
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论