提交 f0a58c50 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Fix almost all the tests.

上级 12b74a54
......@@ -4996,7 +4996,7 @@ class T_scalarfromtensor(unittest.TestCase):
self.assertTrue(v == 56, v)
if config.cast_policy == 'custom':
self.assertTrue(isinstance(v, numpy.int16))
self.assertTrue(isinstance(v, numpy.int8))
elif config.cast_policy in ('numpy', 'numpy+floatX'):
self.assertTrue(isinstance(
v, getattr(numpy, str(numpy.asarray(56).dtype))))
......@@ -7108,7 +7108,7 @@ class T_as_tensor_variable(unittest.TestCase):
def test_ndarray_bool(self):
ten = as_tensor_variable(numpy.array([True, False, False, True, True]))
assert ten.type.dtype == 'uint8'
assert ten.type.dtype == 'bool'
def test_memmap(self):
inp = numpy.random.rand(4, 3)
......
......@@ -812,6 +812,7 @@ class T_reduce_dtype(unittest.TestCase):
def test_reduce_default_acc_dtype(self):
# Test the default acc_dtype of a reduce().
# We try multiple axis combinations even though axis should not matter.
for method in self.methods:
for idx, dtype in enumerate(self.dtypes):
......@@ -839,6 +840,7 @@ class T_reduce_dtype(unittest.TestCase):
@attr('slow')
def test_reduce_custom_dtype(self):
# Test the ability to provide your own output dtype for a reduce.
# We try multiple axis combinations even though axis should not matter.
idx = 0
for method in self.methods:
......@@ -872,6 +874,7 @@ class T_reduce_dtype(unittest.TestCase):
def test_reduce_custom_acc_dtype(self):
# Test the ability to provide your own accumulator dtype for a reduce.
# We try multiple axis combinations even though axis should not matter.
idx = 0
for method in self.methods:
......@@ -928,9 +931,8 @@ class T_reduce_dtype(unittest.TestCase):
class T_mean_dtype(unittest.TestCase):
def test_mean_default_dtype(self):
"""
Test the default dtype of a mean().
"""
# Test the default dtype of a mean().
# We try multiple axis combinations even though axis should not matter.
axes = [None, 0, 1, [], [0], [1], [0, 1]]
for idx, dtype in enumerate(imap(str, theano.scalar.all_types)):
......@@ -948,9 +950,8 @@ class T_mean_dtype(unittest.TestCase):
@attr('slow')
def test_mean_custom_dtype(self):
"""
Test the ability to provide your own output dtype for a mean.
"""
# Test the ability to provide your own output dtype for a mean.
# We try multiple axis combinations even though axis should not matter.
axes = [None, 0, 1, [], [0], [1], [0, 1]]
idx = 0
......@@ -1007,9 +1008,8 @@ class T_mean_dtype(unittest.TestCase):
class T_prod_without_zeros_dtype(unittest.TestCase):
def test_prod_without_zeros_default_dtype(self):
"""
Test the default dtype of a ProdWithoutZeros().
"""
# Test the default dtype of a ProdWithoutZeros().
# We try multiple axis combinations even though axis should not matter.
axes = [None, 0, 1, [], [0], [1], [0, 1]]
for idx, dtype in enumerate(imap(str, theano.scalar.all_types)):
......@@ -1025,9 +1025,8 @@ class T_prod_without_zeros_dtype(unittest.TestCase):
).get(dtype, dtype)
def test_prod_without_zeros_default_acc_dtype(self):
"""
Test the default dtype of a ProdWithoutZeros().
"""
# Test the default dtype of a ProdWithoutZeros().
# We try multiple axis combinations even though axis should not matter.
axes = [None, 0, 1, [], [0], [1], [0, 1]]
for idx, dtype in enumerate(imap(str, theano.scalar.all_types)):
......@@ -1055,9 +1054,8 @@ class T_prod_without_zeros_dtype(unittest.TestCase):
@attr('slow')
def test_prod_without_zeros_custom_dtype(self):
"""
Test ability to provide your own output dtype for a ProdWithoutZeros().
"""
# Test ability to provide your own output dtype for a ProdWithoutZeros().
# We try multiple axis combinations even though axis should not matter.
axes = [None, 0, 1, [], [0], [1], [0, 1]]
idx = 0
......@@ -1079,9 +1077,8 @@ class T_prod_without_zeros_dtype(unittest.TestCase):
@attr('slow')
def test_prod_without_zeros_custom_acc_dtype(self):
"""
Test ability to provide your own acc_dtype for a ProdWithoutZeros().
"""
# Test ability to provide your own acc_dtype for a ProdWithoutZeros().
# We try multiple axis combinations even though axis should not matter.
axes = [None, 0, 1, [], [0], [1], [0, 1]]
idx = 0
......
......@@ -341,7 +341,7 @@ class TensorType(Type):
return False
if a.dtype != b.dtype:
return False
if 'float' not in str(a.dtype):
if str(a.dtype) not in theano.tensor.continuous_dtypes:
return numpy.all(a == b)
else:
cmp = theano.tensor.basic._allclose(a, b, rtol=rtol, atol=atol)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论