提交 4156fa01 authored 作者: David Warde-Farley's avatar David Warde-Farley 提交者: Arnaud Bergeron

Numeric literal fixes.

上级 e14e9c33
...@@ -185,7 +185,7 @@ def filter_compiledir(path): ...@@ -185,7 +185,7 @@ def filter_compiledir(path):
" or listing permissions." % path) " or listing permissions." % path)
else: else:
try: try:
os.makedirs(path, 0770) # read-write-execute for user and group os.makedirs(path, 0o770) # read-write-execute for user and group
except OSError as e: except OSError as e:
# Maybe another parallel execution of theano was trying to create # Maybe another parallel execution of theano was trying to create
# the same directory at the same time. # the same directory at the same time.
......
...@@ -4980,7 +4980,7 @@ class T_reshape(utt.InferShapeTester, utt.TestOptimizationMixin): ...@@ -4980,7 +4980,7 @@ class T_reshape(utt.InferShapeTester, utt.TestOptimizationMixin):
def test_reshape_long_in_shape(self): def test_reshape_long_in_shape(self):
v = dvector('v') v = dvector('v')
r = v.reshape((v.shape[0], 1L)) r = v.reshape((v.shape[0], 1))
print(r.eval({v: numpy.arange(5.)})) print(r.eval({v: numpy.arange(5.)}))
assert numpy.allclose(r.eval({v: numpy.arange(5.)}).T, assert numpy.allclose(r.eval({v: numpy.arange(5.)}).T,
numpy.arange(5.)) numpy.arange(5.))
...@@ -6022,7 +6022,7 @@ def _test_autocast_numpy(): ...@@ -6022,7 +6022,7 @@ def _test_autocast_numpy():
def ok(z): def ok(z):
assert tensor.constant(z).dtype == numpy.asarray(z).dtype assert tensor.constant(z).dtype == numpy.asarray(z).dtype
for x in ([2 ** i for i in xrange(63)] + for x in ([2 ** i for i in xrange(63)] +
[0, 0L, 1L, 2L ** 63 - 1] + [0, 0, 1, 2 ** 63 - 1] +
[0., 1., 1.1, 1.5]): [0., 1., 1.1, 1.5]):
n_x = numpy.asarray(x) n_x = numpy.asarray(x)
# Make sure the data type is the same as the one found by numpy. # Make sure the data type is the same as the one found by numpy.
...@@ -6055,7 +6055,7 @@ def _test_autocast_numpy_floatX(): ...@@ -6055,7 +6055,7 @@ def _test_autocast_numpy_floatX():
# into int64, as that is the maximal integer type that Theano # into int64, as that is the maximal integer type that Theano
# supports, and that is the maximal type in Python indexing. # supports, and that is the maximal type in Python indexing.
for x in ([2 ** i - 1 for i in xrange(64)] + for x in ([2 ** i - 1 for i in xrange(64)] +
[0, 0L, 1L, 2L ** 63 - 1] + [0, 0, 1, 2 ** 63 - 1] +
[0., 1., 1.1, 1.5]): [0., 1., 1.1, 1.5]):
ok(x, floatX) ok(x, floatX)
ok(-x, floatX) ok(-x, floatX)
...@@ -6215,7 +6215,7 @@ class test_arithmetic_cast(unittest.TestCase): ...@@ -6215,7 +6215,7 @@ class test_arithmetic_cast(unittest.TestCase):
class T_long_tensor(unittest.TestCase): class T_long_tensor(unittest.TestCase):
def test_fit_int64(self): def test_fit_int64(self):
for exp in xrange(64): for exp in xrange(64):
val = 2L ** exp - 1 val = 2 ** exp - 1
scalar_ct = constant(val) scalar_ct = constant(val)
assert scalar_ct.dtype.startswith('int') assert scalar_ct.dtype.startswith('int')
assert scalar_ct.value == val assert scalar_ct.value == val
...@@ -6229,7 +6229,7 @@ class T_long_tensor(unittest.TestCase): ...@@ -6229,7 +6229,7 @@ class T_long_tensor(unittest.TestCase):
assert numpy.all(matrix_ct.value == val) assert numpy.all(matrix_ct.value == val)
def test_too_big(self): def test_too_big(self):
val = 2L ** 63 val = 2 ** 63
# NumPy 1.7 this will raise an exception # NumPy 1.7 this will raise an exception
# NumPy 1.7.1 this will work # NumPy 1.7.1 this will work
try: try:
...@@ -6256,7 +6256,7 @@ class T_long_tensor(unittest.TestCase): ...@@ -6256,7 +6256,7 @@ class T_long_tensor(unittest.TestCase):
except TypeError: except TypeError:
pass pass
val = 2L ** 64 val = 2 ** 64
# This fail for all NumPy version. # This fail for all NumPy version.
self.assertRaises(Exception, constant, val) self.assertRaises(Exception, constant, val)
self.assertRaises(Exception, constant, [val, val]) self.assertRaises(Exception, constant, [val, val])
......
...@@ -303,7 +303,7 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin): ...@@ -303,7 +303,7 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
def test_long(self): def test_long(self):
n = self.shared(numpy.arange(12, dtype=self.dtype).reshape((4, 3))) n = self.shared(numpy.arange(12, dtype=self.dtype).reshape((4, 3)))
t = n[1L:4L:2L, 1L] t = n[1:4:2, 1]
self.assertTrue(isinstance(t.owner.op, Subtensor)) self.assertTrue(isinstance(t.owner.op, Subtensor))
tval = self.eval_output_and_check(t) tval = self.eval_output_and_check(t)
self.assertTrue(tval.shape == (2,)) self.assertTrue(tval.shape == (2,))
...@@ -313,7 +313,7 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin): ...@@ -313,7 +313,7 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
# Currently, we cast Python longs to int64 when used for indexing. # Currently, we cast Python longs to int64 when used for indexing.
# This test checks that using a long that does not fit raises an error. # This test checks that using a long that does not fit raises an error.
n = self.shared(numpy.arange(12, dtype=self.dtype).reshape((4, 3))) n = self.shared(numpy.arange(12, dtype=self.dtype).reshape((4, 3)))
self.assertRaises(Exception, lambda: n[:(2L ** 63)]) self.assertRaises(Exception, lambda: n[:(2 ** 63)])
def test_list_slice(self): def test_list_slice(self):
x = theano.tensor.arange(100).reshape((5, 5, 4)) x = theano.tensor.arange(100).reshape((5, 5, 4))
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论