提交 7320ff5e authored 作者: David Warde-Farley's avatar David Warde-Farley

PEP8 fixes to tensor.roll.

上级 4dec97f7
...@@ -4290,6 +4290,7 @@ def join(axis, *tensors): ...@@ -4290,6 +4290,7 @@ def join(axis, *tensors):
pprint.assign(lambda pstate, r: r.owner and isinstance(r.owner.op, Join), pprint.assign(lambda pstate, r: r.owner and isinstance(r.owner.op, Join),
printing.FunctionPrinter('join')) printing.FunctionPrinter('join'))
def roll(x, shift, axis=0): def roll(x, shift, axis=0):
""" """
Convenience function to roll `TensorType`s along the given axis. Convenience function to roll `TensorType`s along the given axis.
...@@ -4313,11 +4314,13 @@ def roll(x, shift, axis=0): ...@@ -4313,11 +4314,13 @@ def roll(x, shift, axis=0):
[allslice] * (x.ndim - axis - 1)) [allslice] * (x.ndim - axis - 1))
# List of slices describing the back half [:, :, :shift, :] # List of slices describing the back half [:, :, :shift, :]
end_slice = slice(0, -shift) end_slice = slice(0, -shift)
end_list = [allslice]*axis + [end_slice] + [allslice]*(x.ndim-axis-1) end_list = ([allslice] * axis + [end_slice] +
[allslice] * (x.ndim - axis - 1))
return join(axis, return join(axis,
Subtensor(front_list)(x), Subtensor(front_list)(x),
Subtensor(end_list)(x)) Subtensor(end_list)(x))
@constructor @constructor
def shape_padleft(t, n_ones=1): def shape_padleft(t, n_ones=1):
"""Reshape `t` by left-padding the shape with `n_ones` 1s """Reshape `t` by left-padding the shape with `n_ones` 1s
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论