提交 9fbfae94 authored 作者: Frederic Bastien's avatar Frederic Bastien 提交者: Alexander Belopolsky

Fix error not raised in python 3.

This change the behavior a little. Now int are casted into numpy.int64. This is needed as in Python3 long have replaced int and there are no more long! So the int case will be used in Python 3. Forcing the type isn't a problem as we support only this type for shape everywhere in Theano.
上级 5dab84e7
......@@ -4609,12 +4609,13 @@ class Subtensor(Op):
# There is a bug in numpy that results in isinstance(x, int) returning
# False for numpy integers.
# See <http://projects.scipy.org/numpy/ticket/2235>.
elif isinstance(entry, (numpy.integer, int)):
elif isinstance(entry, numpy.integer):
return entry
# On Windows 64-bit, shapes are returned as Python long, as they can
# be bigger than what a Python int can hold.
# Shapes should always fit in a numpy.int64, and we support them better
elif isinstance(entry, long):
# 2) In Python3, long replaced int. So we must assert it fit in int64.
elif isinstance(entry, (int, long)):
entry64 = numpy.int64(entry)
return entry64
else:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论