提交 b547aa90 authored 作者: Frédéric Bastien's avatar Frédéric Bastien 提交者: GitHub

Merge pull request #5885 from AndreiCostinescu/patch-1

Corrected some comments and code formatting
...@@ -1353,8 +1353,8 @@ class CAReduce(Op): ...@@ -1353,8 +1353,8 @@ class CAReduce(Op):
axis2.append(a) axis2.append(a)
assert len(axis) == len(axis2) assert len(axis) == len(axis2)
axis = tuple(axis2) axis = tuple(axis2)
# We can't call self.__class__() as there is class that # We can't call self.__class__() as there is a class that
# inherit from CAReduce that don't have the same signature # inherits from CAReduce that doesn't have the same signature
op = copy(self) op = copy(self)
op.set_ufunc(op.scalar_op) op.set_ufunc(op.scalar_op)
op.axis = axis op.axis = axis
...@@ -1398,7 +1398,7 @@ class CAReduce(Op): ...@@ -1398,7 +1398,7 @@ class CAReduce(Op):
if to_reduce: if to_reduce:
for dimension in to_reduce: for dimension in to_reduce:
# If it's a zero-size array, use scalar_op.identity # If it's a zero-sized array, use scalar_op.identity
# if available # if available
if variable.shape[dimension] == 0: if variable.shape[dimension] == 0:
if hasattr(self.scalar_op, 'identity'): if hasattr(self.scalar_op, 'identity'):
...@@ -1553,14 +1553,14 @@ class CAReduce(Op): ...@@ -1553,14 +1553,14 @@ class CAReduce(Op):
pattern_ = str(pattern)[1:-1] pattern_ = str(pattern)[1:-1]
decl += """int tosum[]={%(pattern_)s};""" % locals() decl += """int tosum[]={%(pattern_)s};""" % locals()
alloc += """ alloc += """
for(int i=0;i<PyArray_NDIM(%(iname)s);i++){ for(int i=0;i<PyArray_NDIM(%(iname)s);i++){
if(PyArray_DIMS(%(iname)s)[i]==0 && tosum[i]){ if(PyArray_DIMS(%(iname)s)[i]==0 && tosum[i]){
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"Input of CAReduce{%(scal_name)s} has zero-size on axis %%d",i); "Input of CAReduce{%(scal_name)s} has zero-size on axis %%d",i);
%(fail)s; %(fail)s;
} }
} }
""" % locals() """ % locals()
else: else:
raise TypeError( raise TypeError(
"The CAReduce.scalar_op must have an identity field.") "The CAReduce.scalar_op must have an identity field.")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论