提交 d6479fdb authored 作者: Frederic's avatar Frederic

small typo/cleaner code following review comments

上级 da2182ef
......@@ -32,8 +32,8 @@ New Features
* If you use Enthought Python Distribution (EPD) now we use its blas
implementation by default (tested on Linux and Windows)
(Frederic B., Simon McGregor)
* MRG random now raise an error with a clear message when the passed shape
contain dimensions with bad value like 0. (Frédéric B. reported by Ian G.)
* MRG random now raises an error with a clear message when the passed shape
contains dimensions with bad value like 0. (Frédéric B. reported by Ian G.)
Sparse Sandbox graduate
* Remove0 op: it removes stored elements with value 0. (Frederic B.)
......
......@@ -730,9 +730,9 @@ class MRG_RandomStreams(object):
msg = "size must be a tuple of int or a Theano variable"
assert all([isinstance(i,int) or isinstance(i,Variable)
for i in size]), msg
if len([i for i in size if isinstance(i, int) and i <= 0]) > 0:
if any([isinstance(i, int) and i <= 0 for i in size]):
raise ValueError(
"The specified size contain a dimension with value <= 0",
"The specified size contains a dimension with value <= 0",
size)
else:
......@@ -803,9 +803,9 @@ class MRG_RandomStreams(object):
raise TypeError("You have to specify pvals")
pvals = as_tensor_variable(pvals)
if size is not None:
if any([i for i in size if not (isinstance(i, int) and i <= 0)]):
if any([isinstance(i, int) and i <= 0 for i in size]):
raise ValueError(
"The specified size contain a dimension with value <= 0",
"The specified size contains a dimension with value <= 0",
size)
if n == 1 and pvals.ndim == 2:
......
......@@ -604,10 +604,10 @@ class T_MRG(unittest.TestCase):
R = MRG_RandomStreams(234, use_cuda=False)
for size, var_input in [
((0, 100), []),
((-1, 100), []),
((1, 0), []),
for size in [
(0, 100),
(-1, 100),
(1, 0),
]:
self.assertRaises(ValueError, R.uniform, size)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论