提交 f9f931ae authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Small fixes for Python 2.4

上级 ec674d80
...@@ -1185,6 +1185,9 @@ def local_subtensor_make_vector(node): ...@@ -1185,6 +1185,9 @@ def local_subtensor_make_vector(node):
# if it is a constant we can do something with it # if it is a constant we can do something with it
try: try:
v = get_scalar_constant_value(idx) v = get_scalar_constant_value(idx)
if isinstance(v, numpy.integer):
# Python 2.4 wants to index only with Python integers
v = int(v)
return [x.owner.inputs[v]] return [x.owner.inputs[v]]
except NotScalarConstantError: except NotScalarConstantError:
pass pass
......
...@@ -5,6 +5,7 @@ import sys ...@@ -5,6 +5,7 @@ import sys
import theano.tensor as T import theano.tensor as T
from theano import tensor from theano import tensor
from theano.gof.python25 import product as itertools_product from theano.gof.python25 import product as itertools_product
from theano.gof.python25 import any
from theano.printing import pp from theano.printing import pp
import numpy import numpy
...@@ -857,7 +858,6 @@ def test_dot22(): ...@@ -857,7 +858,6 @@ def test_dot22():
assert _dot22 in [x.op for x in topo], (dtype1, dtype2) assert _dot22 in [x.op for x in topo], (dtype1, dtype2)
else: else:
check = [isinstance(x.op, T.Dot) for x in topo] check = [isinstance(x.op, T.Dot) for x in topo]
from theano.gof.python25 import any
assert any(check), (dtype1, dtype2) assert any(check), (dtype1, dtype2)
rng = numpy.random.RandomState(unittest_tools.fetch_seed()) rng = numpy.random.RandomState(unittest_tools.fetch_seed())
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论