提交 50b12241 authored 作者: Frederic's avatar Frederic

pep8

上级 21e3415f
...@@ -1750,7 +1750,7 @@ class AddSD(gof.op.Op): ...@@ -1750,7 +1750,7 @@ class AddSD(gof.op.Op):
def c_code(self, node, name, (_data, _indices, _indptr, y), (z, ), sub): def c_code(self, node, name, (_data, _indices, _indptr, y), (z, ), sub):
inplace = int(self.inplace) inplace = int(self.inplace)
format = {'csc': 0, 'csr':1}[self.format] format = {'csc': 0, 'csr': 1}[self.format]
code = """ code = """
Py_XDECREF(%(z)s); Py_XDECREF(%(z)s);
if (!%(inplace)s){ if (!%(inplace)s){
...@@ -1759,7 +1759,7 @@ class AddSD(gof.op.Op): ...@@ -1759,7 +1759,7 @@ class AddSD(gof.op.Op):
%(z)s = %(y)s; %(z)s = %(y)s;
Py_XINCREF(%(z)s); Py_XINCREF(%(z)s);
} }
npy_intp N = PyArray_DIMS(%(_indptr)s)[0]-1; npy_intp N = PyArray_DIMS(%(_indptr)s)[0]-1;
const npy_int32 * __restrict__ indptr = (npy_int32 *)%(_indptr)s->data; const npy_int32 * __restrict__ indptr = (npy_int32 *)%(_indptr)s->data;
const npy_int32 * __restrict__ indices = (npy_int32*)%(_indices)s->data; const npy_int32 * __restrict__ indices = (npy_int32*)%(_indices)s->data;
...@@ -1795,9 +1795,9 @@ class AddSD(gof.op.Op): ...@@ -1795,9 +1795,9 @@ class AddSD(gof.op.Op):
assert _is_dense(y) assert _is_dense(y)
if self.format == 'csr': if self.format == 'csr':
x = scipy.sparse.csr_matrix((data, indices, indptr), shape = y.shape) x = scipy.sparse.csr_matrix((data, indices, indptr), shape=y.shape)
elif self.format == 'csc': elif self.format == 'csc':
x = scipy.sparse.csc_matrix((data, indices, indptr), shape = y.shape) x = scipy.sparse.csc_matrix((data, indices, indptr), shape=y.shape)
# The asarray is needed as in some case, this return a # The asarray is needed as in some case, this return a
# numpy.matrixlib.defmatrix.matrix object and not an ndarray. # numpy.matrixlib.defmatrix.matrix object and not an ndarray.
......
...@@ -506,8 +506,8 @@ class T_AddMul(unittest.TestCase): ...@@ -506,8 +506,8 @@ class T_AddMul(unittest.TestCase):
elif op is mul: elif op is mul:
self.assertTrue(_is_sparse_variable(apb)) self.assertTrue(_is_sparse_variable(apb))
self.assertTrue(numpy.all(val.todense() == (b.multiply(a)))) self.assertTrue(numpy.all(val.todense() == (b.multiply(a))))
self.assertTrue(numpy.all(val.todense() == numpy.array([[1, 0], self.assertTrue(numpy.all(val.todense() == numpy.array(
[9, 0], [0, 36]]))) [[1, 0], [9, 0], [0, 36]])))
def _testDS(self, op, array1=numpy.array([[1., 0], [3, 0], [0, 6]]), def _testDS(self, op, array1=numpy.array([[1., 0], [3, 0], [0, 6]]),
array2=numpy.asarray([[0, 2.], [0, 4], [5, 0]])): array2=numpy.asarray([[0, 2.], [0, 4], [5, 0]])):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论