提交 4da8ba40 authored 作者: David Warde-Farley's avatar David Warde-Farley

STY: readability + pep8

上级 02101b23
......@@ -278,7 +278,13 @@ class DimShuffle(Op):
# set the strides of the broadcasted dimensions
# this algorithm is from numpy: PyArray_Newshape() in cvs/numpy/numpy/core/src/multiarraymodule.c
if nd_out > 0:
strides_statements.append('if (strides['+str(nd_out)+'-1] == 0) strides['+str(nd_out)+'-1] = %(basename)s->descr->elsize')
strides_statements.append(
'if (strides[' +
str(nd_out) +
'-1] == 0) strides[' +
str(nd_out) +
'-1] = %(basename)s->descr->elsize'
)
for i in xrange(nd_out-2,-1, -1):
strides_statements.append("if (strides[%(i)s] == 0) strides[%(i)s] = strides[%(i)s+1] * dimensions[%(i)s+1]"%dict(i=str(i)))
......
......@@ -28,7 +28,7 @@ class test_DimShuffle(unittest.TestCase):
((1, 4, 3, 2, 1), (3, 2, 1), (2, 3, 4)),
((1, 1, 4), (1, 2), (1, 4)),
((1, 1, 1), (), ()),
((1,), ('x','x'), (1,1)),]:
((1,), ('x', 'x'), (1, 1)),]:
ib = [(entry == 1) for entry in xsh]
x = TensorType('float64', ib)('x')
e = DimShuffle(ib, shuffle)(x)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论