提交 a78a9a80 authored 作者: Frederic's avatar Frederic

pep8

上级 36152c6c
...@@ -2,17 +2,12 @@ import gc ...@@ -2,17 +2,12 @@ import gc
import sys import sys
import time import time
import unittest import unittest
try:
import line_profiler
except ImportError:
pass
from nose.plugins.skip import SkipTest from nose.plugins.skip import SkipTest
import numpy import numpy
from theano import function from theano import function
from theano.gof import vm from theano.gof import vm
from theano.gof import link
from theano.gof import OpWiseCLinker from theano.gof import OpWiseCLinker
from theano.compile import Mode from theano.compile import Mode
...@@ -43,7 +38,8 @@ class TestCallbacks(unittest.TestCase): ...@@ -43,7 +38,8 @@ class TestCallbacks(unittest.TestCase):
f(1, 2, 3) f(1, 2, 3)
assert sum(self.n_callbacks.values()) == len(f.maker.fgraph.toposort()) assert sum(self.n_callbacks.values()) == len(f.maker.fgraph.toposort())
f(1, 2, 3) f(1, 2, 3)
assert sum(self.n_callbacks.values()) == len(f.maker.fgraph.toposort()) * 2 assert (sum(self.n_callbacks.values()) ==
len(f.maker.fgraph.toposort()) * 2)
def test_callback_with_ifelse(self): def test_callback_with_ifelse(self):
a, b, c = tensor.scalars('abc') a, b, c = tensor.scalars('abc')
...@@ -99,13 +95,9 @@ def test_speed(): ...@@ -99,13 +95,9 @@ def test_speed():
b = build_graph(x, steps_b) b = build_graph(x, steps_b)
f_a = function([x], a, f_a = function([x], a,
mode=Mode(optimizer=None, linker=linker()), mode=Mode(optimizer=None, linker=linker()))
#profile='f_a speed test %s'%name,
)
f_b = function([x], b, f_b = function([x], b,
mode=Mode(optimizer=None, linker=linker()), mode=Mode(optimizer=None, linker=linker()))
#profile='f_b speed test %s'%name,
)
f_a([2.0, 3.0]) f_a([2.0, 3.0])
t0 = time.time() t0 = time.time()
...@@ -151,14 +143,10 @@ def test_speed_lazy(): ...@@ -151,14 +143,10 @@ def test_speed_lazy():
f_a = function([x], a, f_a = function([x], a,
mode=Mode(optimizer=None, mode=Mode(optimizer=None,
linker=linker()), linker=linker()))
#profile='f_a lazy ifelse %s'%name,
)
f_b = function([x], b, f_b = function([x], b,
mode=Mode(optimizer=None, mode=Mode(optimizer=None,
linker=linker()), linker=linker()))
#profile='f_b lazy ifelse %s'%name,
)
f_a([2.0]) f_a([2.0])
t0 = time.time() t0 = time.time()
...@@ -218,7 +206,7 @@ if run_memory_usage_tests: ...@@ -218,7 +206,7 @@ if run_memory_usage_tests:
for i in xrange(1000000): for i in xrange(1000000):
n = numpy.asarray([2.3, 4.5], dtype='f') n = numpy.asarray([2.3, 4.5], dtype='f')
c = sys.getrefcount(n) c = sys.getrefcount(n)
a = cuda.CudaNdarray(n) cuda.CudaNdarray(n)
assert c == sys.getrefcount(n) assert c == sys.getrefcount(n)
if not i % 1000: if not i % 1000:
print '.', print '.',
...@@ -258,7 +246,7 @@ if run_memory_usage_tests: ...@@ -258,7 +246,7 @@ if run_memory_usage_tests:
def build_graph(x, depth=5): def build_graph(x, depth=5):
z = x z = x
for d in range(depth): for d in range(depth):
z = ifelse(z.mean()>0.5, -z, z) z = ifelse(z.mean() > 0.5, -z, z)
return z return z
def time_linker(name, linker): def time_linker(name, linker):
......
...@@ -320,7 +320,6 @@ whitelist_flake8 = [ ...@@ -320,7 +320,6 @@ whitelist_flake8 = [
"gof/tests/test_destroyhandler.py", "gof/tests/test_destroyhandler.py",
"gof/tests/test_opt.py", "gof/tests/test_opt.py",
"gof/tests/test_lazy.py", "gof/tests/test_lazy.py",
"gof/tests/test_vm.py",
"gof/tests/test_toolbox.py", "gof/tests/test_toolbox.py",
"gof/tests/test_link.py", "gof/tests/test_link.py",
"gof/tests/test_fg.py", "gof/tests/test_fg.py",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论