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

Make test work with python3

上级 3b9fdd10
...@@ -17,6 +17,7 @@ from theano.gof.python25 import any ...@@ -17,6 +17,7 @@ from theano.gof.python25 import any
from theano.tests import unittest_tools as utt from theano.tests import unittest_tools as utt
import theano.scalar.sharedvar import theano.scalar.sharedvar
from theano.gof.python25 import OrderedDict from theano.gof.python25 import OrderedDict
from theano.compat import PY3
from numpy.testing.noseclasses import KnownFailureTest from numpy.testing.noseclasses import KnownFailureTest
...@@ -3515,12 +3516,20 @@ def test_speed(): ...@@ -3515,12 +3516,20 @@ def test_speed():
t0 = time.time() t0 = time.time()
r_i = iter(r[1:]) r_i = iter(r[1:])
r_ii = iter(r[:-1]) r_ii = iter(r[:-1])
while True: if PY3:
try: while True:
tmp = r_i.next() try:
tmp += r_ii.next() tmp = next(r_i)
except StopIteration: tmp += next(r_ii)
break except StopIteration:
break
else:
while True:
try:
tmp = r_i.next()
tmp += r_ii.next()
except StopIteration:
break
t1 = time.time() t1 = time.time()
print 'python with builtin iterator', t1 - t0 print 'python with builtin iterator', t1 - t0
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论