提交 0f89dd53 authored 作者: Frederic's avatar Frederic

pep8

上级 0884f7d3
......@@ -36,7 +36,7 @@ class _typed_list_py_operators:
def count(self, elem):
return count(self, elem)
#name "index" is already used by an attribute
# name "index" is already used by an attribute
def ind(self, elem):
return index_(self, elem)
......
......@@ -21,13 +21,13 @@ except ImportError:
scipy_imported = False
#took from tensors/tests/test_basic.py
# took from tensors/tests/test_basic.py
def rand_ranged_matrix(minimum, maximum, shape):
return numpy.asarray(numpy.random.rand(*shape) * (maximum - minimum)
+ minimum, dtype=theano.config.floatX)
#took from sparse/tests/test_basic.py
# took from sparse/tests/test_basic.py
def random_lil(shape, dtype, nnz):
rval = sp.lil_matrix(shape, dtype=dtype)
huge = 2 ** 30
......@@ -35,7 +35,7 @@ def random_lil(shape, dtype, nnz):
# set non-zeros in random locations (row x, col y)
idx = numpy.random.random_integers(huge, size=2) % shape
value = numpy.random.rand()
#if dtype *int*, value will always be zeros!
# if dtype *int*, value will always be zeros!
if "int" in dtype:
value = int(value * 100)
# The call to tuple is needed as scipy 0.13.1 do not support
......@@ -84,8 +84,9 @@ class test_get_item(unittest.TestCase):
x = rand_ranged_matrix(-1000, 1000, [100, 101])
y = rand_ranged_matrix(-1000, 1000, [100, 101])
self.assertTrue(numpy.array_equal(f([x], numpy.asarray(0,
dtype='int64')), x))
self.assertTrue(numpy.array_equal(f([x],
numpy.asarray(0, dtype='int64')),
x))
def test_interface(self):
mySymbolicMatricesList = TypedListType(T.TensorType(
......@@ -99,8 +100,9 @@ class test_get_item(unittest.TestCase):
x = rand_ranged_matrix(-1000, 1000, [100, 101])
self.assertTrue(numpy.array_equal(f([x], numpy.asarray(0,
dtype='int64')), x))
self.assertTrue(numpy.array_equal(f([x],
numpy.asarray(0, dtype='int64')),
x))
z = mySymbolicMatricesList[0]
......@@ -258,8 +260,10 @@ class test_insert(unittest.TestCase):
y = rand_ranged_matrix(-1000, 1000, [100, 101])
self.assertTrue(numpy.array_equal(f([x], numpy.asarray(1,
dtype='int64'), y), [x, y]))
self.assertTrue(numpy.array_equal(f([x],
numpy.asarray(1, dtype='int64'),
y),
[x, y]))
def test_sanity_check(self):
mySymbolicMatricesList = TypedListType(T.TensorType(
......@@ -292,8 +296,10 @@ class test_insert(unittest.TestCase):
y = rand_ranged_matrix(-1000, 1000, [100, 101])
self.assertTrue(numpy.array_equal(f([x], numpy.asarray(1,
dtype='int64'), y), [x, y]))
self.assertTrue(numpy.array_equal(f([x],
numpy.asarray(1, dtype='int64'),
y),
[x, y]))
class test_remove(unittest.TestCase):
......@@ -443,8 +449,8 @@ class test_index(unittest.TestCase):
def test_sparse(self):
if not scipy_imported:
raise SkipTest('Optional package SciPy not installed')
mySymbolicSparseList = TypedListType(sparse.SparseType('csr',
theano.config.floatX))()
mySymbolicSparseList = TypedListType(
sparse.SparseType('csr', theano.config.floatX))()
mySymbolicSparse = sparse.csr_matrix()
z = Index()(mySymbolicSparseList, mySymbolicSparse)
......@@ -509,8 +515,8 @@ class test_count(unittest.TestCase):
def test_sparse(self):
if not scipy_imported:
raise SkipTest('Optional package SciPy not installed')
mySymbolicSparseList = TypedListType(sparse.SparseType('csr',
theano.config.floatX))()
mySymbolicSparseList = TypedListType(
sparse.SparseType('csr', theano.config.floatX))()
mySymbolicSparse = sparse.csr_matrix()
z = Count()(mySymbolicSparseList, mySymbolicSparse)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论