提交 2ec83e4a authored 作者: Saizheng Zhang's avatar Saizheng Zhang

flake8 errors fixed

上级 5d042f51
"""A `Type` and `Op` classes to work with numpy.ndarrays symbolically.""" """A `Type` and `Op` classes to work with numpy.ndarrays symbolically."""
import __builtin__ from six.moves import builtins
import sys import sys
import warnings import warnings
...@@ -4743,17 +4743,17 @@ def tile(x, reps, ndim=None): ...@@ -4743,17 +4743,17 @@ def tile(x, reps, ndim=None):
raise ValueError("if reps is tensor.vector, you should specify " raise ValueError("if reps is tensor.vector, you should specify "
"the ndim") "the ndim")
else: else:
offset = ndim-reps.shape[0] offset = ndim - reps.shape[0]
# assert that reps.shape[0] does not exceed ndim # assert that reps.shape[0] does not exceed ndim
offset = theano.tensor.opt.assert_(offset, ge(offset, 0)) offset = theano.tensor.opt.assert_(offset, ge(offset, 0))
# if reps.ndim is less than x.ndim, we pad the reps with # if reps.ndim is less than x.ndim, we pad the reps with
# "1" so that reps will have the same ndim as x. # "1" so that reps will have the same ndim as x.
reps_ = [switch(i<offset, 1, reps[i-offset]) for i in range(ndim)] reps_ = [switch(i < offset, 1, reps[i - offset]) for i in range(ndim)]
reps = reps_ reps = reps_
#other raise error # other raise error
else: else:
raise ValueError("the dimension of reps should not exceed 1") raise ValueError("the dimension of reps should not exceed 1")
else: else:
...@@ -4768,11 +4768,11 @@ def tile(x, reps, ndim=None): ...@@ -4768,11 +4768,11 @@ def tile(x, reps, ndim=None):
# "1" so that reps will have the same ndim as x. # "1" so that reps will have the same ndim as x.
reps = list(reps) reps = list(reps)
if ndim is None: if ndim is None:
ndim = __builtin__.max(len(reps), x.ndim) ndim = builtins.max(len(reps), x.ndim)
if len(reps) < ndim: if len(reps) < ndim:
reps = [1]*(ndim-len(reps)) + reps reps = [1] * (ndim - len(reps)) + reps
shape = [1]*(ndim-x.ndim) + [x.shape[i] for i in xrange(x.ndim)] shape = [1] * (ndim - x.ndim) + [x.shape[i] for i in xrange(x.ndim)]
alloc_shape = reps + shape alloc_shape = reps + shape
y = alloc(x, *alloc_shape) y = alloc(x, *alloc_shape)
shuffle_ind = numpy.arange(ndim * 2).reshape(2, ndim) shuffle_ind = numpy.arange(ndim * 2).reshape(2, ndim)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论