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

flake8

上级 2956d27e
...@@ -30,7 +30,6 @@ whitelist_flake8 = [ ...@@ -30,7 +30,6 @@ whitelist_flake8 = [
"tests/test_gradient.py", "tests/test_gradient.py",
"tests/test_config.py", "tests/test_config.py",
"tests/diverse_tests.py", "tests/diverse_tests.py",
"tests/test_ifelse.py",
"tests/test_rop.py", "tests/test_rop.py",
"tests/test_2nd_order_grads.py", "tests/test_2nd_order_grads.py",
"tests/run_tests_in_batch.py", "tests/run_tests_in_batch.py",
......
...@@ -3,11 +3,6 @@ ...@@ -3,11 +3,6 @@
""" """
from __future__ import print_function from __future__ import print_function
__docformat__ = 'restructedtext en'
__authors__ = ("Razvan Pascanu ")
__copyright__ = "(c) 2010, Universite de Montreal"
__contact__ = "Razvan Pascanu <r.pascanu@gmail>"
import unittest import unittest
import numpy import numpy
from nose.plugins.skip import SkipTest from nose.plugins.skip import SkipTest
...@@ -20,6 +15,12 @@ from theano.ifelse import IfElse, ifelse ...@@ -20,6 +15,12 @@ from theano.ifelse import IfElse, ifelse
from theano.tests import unittest_tools as utt from theano.tests import unittest_tools as utt
__docformat__ = 'restructedtext en'
__authors__ = ("Razvan Pascanu ")
__copyright__ = "(c) 2010, Universite de Montreal"
__contact__ = "Razvan Pascanu <r.pascanu@gmail>"
class test_ifelse(unittest.TestCase, utt.TestOptimizationMixin): class test_ifelse(unittest.TestCase, utt.TestOptimizationMixin):
mode = None mode = None
dtype = theano.config.floatX dtype = theano.config.floatX
...@@ -63,7 +64,7 @@ class test_ifelse(unittest.TestCase, utt.TestOptimizationMixin): ...@@ -63,7 +64,7 @@ class test_ifelse(unittest.TestCase, utt.TestOptimizationMixin):
# the opt. # the opt.
'fusion', 'local_add_canonizer', 'fusion', 'local_add_canonizer',
'inplace', 'constant_folding', 'constant_folding') 'inplace', 'constant_folding', 'constant_folding')
y2 = reduce(lambda x, y: x+y, [y] + range(200)) y2 = reduce(lambda x, y: x + y, [y] + range(200))
f = theano.function([c, x, y], ifelse(c, x, y2), mode=mode) f = theano.function([c, x, y], ifelse(c, x, y2), mode=mode)
# For not inplace ifelse # For not inplace ifelse
self.assertFunctionContains1(f, IfElse(1)) self.assertFunctionContains1(f, IfElse(1))
...@@ -92,9 +93,9 @@ class test_ifelse(unittest.TestCase, utt.TestOptimizationMixin): ...@@ -92,9 +93,9 @@ class test_ifelse(unittest.TestCase, utt.TestOptimizationMixin):
xlen = rng.randint(200) xlen = rng.randint(200)
ylen = rng.randint(200) ylen = rng.randint(200)
vx1 = numpy.asarray(rng.uniform(size=(xlen,))*3, 'int32') vx1 = numpy.asarray(rng.uniform(size=(xlen,)) * 3, 'int32')
vx2 = numpy.asarray(rng.uniform(size=(xlen,)), self.dtype) vx2 = numpy.asarray(rng.uniform(size=(xlen,)), self.dtype)
vy1 = numpy.asarray(rng.uniform(size=(ylen,))*3, 'int32') vy1 = numpy.asarray(rng.uniform(size=(ylen,)) * 3, 'int32')
vy2 = numpy.asarray(rng.uniform(size=(ylen,)), self.dtype) vy2 = numpy.asarray(rng.uniform(size=(ylen,)), self.dtype)
o1, o2 = f(1, vx1, vx2, vy1, vy2) o1, o2 = f(1, vx1, vx2, vy1, vy2)
...@@ -315,8 +316,8 @@ class test_ifelse(unittest.TestCase, utt.TestOptimizationMixin): ...@@ -315,8 +316,8 @@ class test_ifelse(unittest.TestCase, utt.TestOptimizationMixin):
z2 = ifelse(c, x + 2, y + 2) z2 = ifelse(c, x + 2, y + 2)
z = z1 + z2 z = z1 + z2
f = theano.function([c, x, y], z) f = theano.function([c, x, y], z)
assert len([x for x in f.maker.fgraph.toposort() assert len([n for n in f.maker.fgraph.toposort()
if isinstance(x.op, IfElse)]) == 1 if isinstance(n.op, IfElse)]) == 1
def test_remove_useless_inputs1(self): def test_remove_useless_inputs1(self):
raise SkipTest("Optimization temporarily disabled") raise SkipTest("Optimization temporarily disabled")
...@@ -326,8 +327,8 @@ class test_ifelse(unittest.TestCase, utt.TestOptimizationMixin): ...@@ -326,8 +327,8 @@ class test_ifelse(unittest.TestCase, utt.TestOptimizationMixin):
z = ifelse(c, (x, x), (y, y)) z = ifelse(c, (x, x), (y, y))
f = theano.function([c, x, y], z) f = theano.function([c, x, y], z)
ifnode = [x for x in f.maker.fgraph.toposort() ifnode = [n for n in f.maker.fgraph.toposort()
if isinstance(x.op, IfElse)][0] if isinstance(n.op, IfElse)][0]
assert len(ifnode.inputs) == 3 assert len(ifnode.inputs) == 3
def test_remove_useless_inputs2(self): def test_remove_useless_inputs2(self):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论