提交 41adddb7 authored 作者: Frederic's avatar Frederic

pep8

上级 9dd0401f
...@@ -2,7 +2,7 @@ import numpy ...@@ -2,7 +2,7 @@ import numpy
import theano import theano
from theano.tensor.utils import (hash_from_ndarray, hash_from_dict, from theano.tensor.utils import (hash_from_ndarray, hash_from_dict,
shape_of_variables) shape_of_variables)
def test_hash_from_ndarray(): def test_hash_from_ndarray():
...@@ -10,18 +10,18 @@ def test_hash_from_ndarray(): ...@@ -10,18 +10,18 @@ def test_hash_from_ndarray():
rng = numpy.random.rand(5, 5) rng = numpy.random.rand(5, 5)
for data in [-2, -1, 0, 1, 2, numpy.zeros((1, 5)), numpy.zeros((1, 6)), for data in [-2, -1, 0, 1, 2, numpy.zeros((1, 5)), numpy.zeros((1, 6)),
# Data buffer empty but different shapes # Data buffer empty but different shapes
numpy.zeros((1, 0)), numpy.zeros((2, 0)), numpy.zeros((1, 0)), numpy.zeros((2, 0)),
# Same data buffer and shapes but different strides # Same data buffer and shapes but different strides
numpy.arange(25).reshape(5, 5), numpy.arange(25).reshape(5, 5),
numpy.arange(25).reshape(5, 5).T, numpy.arange(25).reshape(5, 5).T,
# Same data buffer, shapes and strides but different dtypes # Same data buffer, shapes and strides but different dtypes
numpy.zeros((5, 5), dtype="uint32"), numpy.zeros((5, 5), dtype="uint32"),
numpy.zeros((5, 5), dtype="int32"), numpy.zeros((5, 5), dtype="int32"),
# Test slice # Test slice
rng, rng[1:], rng[:4], rng[1:3], rng[::2], rng[::-1] rng, rng[1:], rng[:4], rng[1:3], rng[::2], rng[::-1]
]: ]:
data = numpy.asarray(data) data = numpy.asarray(data)
hashs.append(hash_from_ndarray(data)) hashs.append(hash_from_ndarray(data))
...@@ -49,6 +49,7 @@ def test_hash_from_dict(): ...@@ -49,6 +49,7 @@ def test_hash_from_dict():
# List are not hashable. So they are transformed into tuple. # List are not hashable. So they are transformed into tuple.
assert hash_from_dict({0: (0,)}) == hash_from_dict({0: [0]}) assert hash_from_dict({0: (0,)}) == hash_from_dict({0: [0]})
def test_shape_of_variables_simple(): def test_shape_of_variables_simple():
x = theano.tensor.matrix('x') x = theano.tensor.matrix('x')
y = x+x y = x+x
...@@ -62,6 +63,7 @@ def test_shape_of_variables_simple(): ...@@ -62,6 +63,7 @@ def test_shape_of_variables_simple():
assert shapes[x] == (5, 1) assert shapes[x] == (5, 1)
assert shapes[y] == (5, 5) assert shapes[y] == (5, 5)
def test_shape_of_variables_subtensor(): def test_shape_of_variables_subtensor():
x = theano.tensor.matrix('x') x = theano.tensor.matrix('x')
subx = x[1:] subx = x[1:]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论