提交 3127e645 authored 作者: Frederic's avatar Frederic

pep8

上级 8dabd398
......@@ -17,7 +17,7 @@ from theano.sparse import enable_sparse
from theano.gof.python25 import all, any, product
if enable_sparse == False:
if not enable_sparse:
raise SkipTest('Optional package sparse disabled')
from theano.sparse.basic import _is_dense, _is_sparse, _mtypes
......@@ -399,7 +399,6 @@ class SparseInferShapeTester(utt.InferShapeTester):
[csc_from_dense(x)],
[numpy.random.randn(10, 40).astype(
config.floatX)],
csc_from_dense.__class__)
def test_sparse_from_list(self):
......@@ -789,7 +788,8 @@ class test_csm(unittest.TestCase):
numpy.asarray(spmat.shape, 'int32'))
col1 = sp_types[format]((res, spmat.indices, spmat.indptr),
shape=numpy.asarray(spmat.shape, 'int32'))[:, 1].data
shape=numpy.asarray(spmat.shape,
'int32'))[:, 1].data
assert numpy.all(col1 == 2)
......@@ -909,8 +909,7 @@ class test_structureddot(unittest.TestCase):
spmat = sp.csc_matrix(spmat)
images = tensor.Tensor(dtype='float32',
broadcastable=[False, False])(
'images')
broadcastable=[False, False])('images')
cscmat = CSC(kerns, spmat.indices[:spmat.size],
spmat.indptr, spmat.shape)
......@@ -931,7 +930,8 @@ class test_structureddot(unittest.TestCase):
#print 'type of kernvals = ', kernvals.dtype
bsize = 3
imvals = 1.0 * numpy.array(numpy.arange(bsize * spmat.shape[1]).\
reshape(bsize, spmat.shape[1]), dtype='float32')
reshape(bsize, spmat.shape[1]),
dtype='float32')
outvals = f(kernvals, imvals)
#print outvals
......@@ -1281,7 +1281,7 @@ class UsmmTests(unittest.TestCase):
for node in topo]) == len(topo) - 5)
new_topo = []
for node in topo:
if not (isinstance(node.op, tensor.Elemwise) and \
if not (isinstance(node.op, tensor.Elemwise) and
isinstance(node.op.scalar_op,
theano.scalar.basic.Cast)):
new_topo.append(node)
......@@ -1571,7 +1571,7 @@ class SpSumTester(utt.InferShapeTester):
shape=(10, 10))
z = theano.sparse.sp_sum(variable[0], axis=axis)
if axis == None:
if axis is None:
assert z.type.broadcastable == ()
else:
assert z.type.broadcastable == (False, )
......@@ -1962,13 +1962,15 @@ class Test_getitem(unittest.TestCase):
# Advanced indexing is not supported
self.assertRaises(ValueError,
x.__getitem__, (tensor.ivector('l'), slice(a, b)))
x.__getitem__,
(tensor.ivector('l'), slice(a, b)))
# Indexing with random things is not supported either
self.assertRaises(ValueError,
x.__getitem__, slice(tensor.fscalar('f'), None))
self.assertRaises(ValueError,
x.__getitem__, (slice(None), slice([1, 3, 4], None)))
x.__getitem__,
(slice(None), slice([1, 3, 4], None)))
def test_GetItemScalar(self):
sparse_formats = ('csc', 'csr')
......@@ -2558,7 +2560,8 @@ class MulSVTester(unittest.TestCase):
mat = numpy.asarray(numpy.random.rand(3), dtype=dtype)
theano.sparse.verify_grad_sparse(mul_s_v,
[spmat, mat], structured=True)
[spmat, mat],
structured=True)
def test_mul_s_v(self):
sp_types = {'csc': sp.csc_matrix,
......@@ -2592,7 +2595,8 @@ class StructuredAddSVTester(unittest.TestCase):
mat = numpy.asarray(numpy.random.rand(3), dtype=dtype)
theano.sparse.verify_grad_sparse(structured_add_s_v,
[spmat, mat], structured=True)
[spmat, mat],
structured=True)
def test_structured_add_s_v(self):
sp_types = {'csc': sp.csc_matrix,
......@@ -2674,7 +2678,7 @@ test_shared_options = theano.tensor.tests.test_sharedvar.makeSharedTester(
ref_fct_=lambda a: numpy.asarray((a * 2).todense()),
cast_value_=scipy.sparse.csr_matrix,
name='test_shared_options',
)
)
if __name__ == '__main__':
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论