提交 47255ce3 authored 作者: Iban Harlouchet's avatar Iban Harlouchet

flake8 for tensor/fourier.py

上级 47853608
......@@ -62,7 +62,7 @@ class Fourier(gof.Op):
(axis.data < 0 or axis.data > a.ndim - 1)):
raise TypeError('%s: index of the transformed axis must be'
' a scalar not smaller than 0 and smaller than'
' dimension of array' % self.__class__.__name__)
' dimension of array' % self.__class__.__name__)
if n is None:
n = a.shape[axis]
n = tensor.as_tensor_variable(n)
......@@ -78,7 +78,7 @@ class Fourier(gof.Op):
' strictly positive scalar'
% self.__class__.__name__)
return gof.Apply(self, [a, n, axis], [tensor.TensorType('complex128',
a.type.broadcastable)()])
a.type.broadcastable)()])
def infer_shape(self, node, in_shapes):
shape_a = in_shapes[0]
......@@ -87,8 +87,8 @@ class Fourier(gof.Op):
if len(shape_a) == 1:
return [(n,)]
elif isinstance(axis, tensor.TensorConstant):
out_shape = list(shape_a[0: axis.data.item()]) + [n] +\
list(shape_a[axis.data + 1:])
out_shape = (list(shape_a[0: axis.data.item()]) + [n] +
list(shape_a[axis.data + 1:]))
else:
l = len(shape_a)
shape_a = tensor.stack(*shape_a)
......@@ -136,7 +136,8 @@ class Fourier(gof.Op):
flip_shape = list(numpy.arange(0, a.ndim)[::-1])
res = res.dimshuffle(flip_shape)
res = tensor.switch(tensor.lt(n, tensor.shape(a)[axis]),
tensor.set_subtensor(res[n::, ], 0, False, False), res)
tensor.set_subtensor(res[n::, ], 0, False, False),
res)
res = res.dimshuffle(flip_shape)
# insures that gradient shape conforms to input shape:
......
......@@ -57,7 +57,6 @@ whitelist_flake8 = [
"typed_list/tests/test_type.py",
"typed_list/tests/test_opt.py",
"typed_list/tests/test_basic.py",
"tensor/fourier.py",
"tensor/__init__.py",
"tensor/opt_uncanonicalize.py",
"tensor/blas.py",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论