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

small typo/cleaner code following review comments

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