提交 0156327d authored 作者: Frederic's avatar Frederic

remove print in tests.

上级 a6c3723c
...@@ -22,9 +22,9 @@ class T_OpFromGraph(unittest.TestCase): ...@@ -22,9 +22,9 @@ class T_OpFromGraph(unittest.TestCase):
xv = numpy.ones((2, 2), dtype=config.floatX) xv = numpy.ones((2, 2), dtype=config.floatX)
yv = numpy.ones((2, 2), dtype=config.floatX)*3 yv = numpy.ones((2, 2), dtype=config.floatX)*3
zv = numpy.ones((2, 2), dtype=config.floatX)*5 zv = numpy.ones((2, 2), dtype=config.floatX)*5
print function, function.__module__ #print function, function.__module__
print fn.maker.env.toposort() #print fn.maker.env.toposort()
print fn(xv, yv, zv) fn(xv, yv, zv)
assert numpy.all(8.0 == fn(xv, yv, zv)) assert numpy.all(8.0 == fn(xv, yv, zv))
assert numpy.all(8.0 == fn(xv, yv, zv)) assert numpy.all(8.0 == fn(xv, yv, zv))
......
...@@ -211,7 +211,7 @@ def test_badclinkeroutput(): ...@@ -211,7 +211,7 @@ def test_badclinkeroutput():
try: try:
f_inconsistent([1.0, 2.0, 3.0], [2, 3, 4]) f_inconsistent([1.0, 2.0, 3.0], [2, 3, 4])
except debugmode.BadCLinkerOutput, e: except debugmode.BadCLinkerOutput, e:
print repr(e) #print repr(e)
assert e.r.owner.op is inconsistent assert e.r.owner.op is inconsistent
return # TEST PASS return # TEST PASS
...@@ -490,7 +490,7 @@ class Test_ViewMap(unittest.TestCase): ...@@ -490,7 +490,7 @@ class Test_ViewMap(unittest.TestCase):
f([1, 2, 3, 4], [5, 6, 7, 8]) f([1, 2, 3, 4], [5, 6, 7, 8])
assert False # DebugMode should have caught the error assert False # DebugMode should have caught the error
except debugmode.BadViewMap, e: except debugmode.BadViewMap, e:
print e #print e
pass pass
# the situation can be rescued by picking one of the inputs and # the situation can be rescued by picking one of the inputs and
...@@ -554,7 +554,7 @@ class Test_check_isfinite(unittest.TestCase): ...@@ -554,7 +554,7 @@ class Test_check_isfinite(unittest.TestCase):
#inf should go through #inf should go through
infs = numpy.asarray([1.0, 1., 1.]) / 0 infs = numpy.asarray([1.0, 1., 1.]) / 0
print infs #print infs
f(infs) f(infs)
return return
...@@ -576,11 +576,11 @@ class BrokenCImplementationAdd(gof.Op): ...@@ -576,11 +576,11 @@ class BrokenCImplementationAdd(gof.Op):
return r return r
def perform(self, node, inp, out_): def perform(self, node, inp, out_):
print 'executing python perform' #print 'executing python perform'
a, b = inp a, b = inp
out, = out_ out, = out_
z = a + b z = a + b
print 'out[0] was:', out[0] #print 'out[0] was:', out[0]
out[0] = z out[0] = z
def c_code_cache_version(self): def c_code_cache_version(self):
......
...@@ -18,7 +18,7 @@ class NNet(object): ...@@ -18,7 +18,7 @@ class NNet(object):
self.lr = shared(lr, 'learning_rate') self.lr = shared(lr, 'learning_rate')
self.w1 = shared(numpy.zeros((n_hidden, n_input)), 'w1') self.w1 = shared(numpy.zeros((n_hidden, n_input)), 'w1')
self.w2 = shared(numpy.zeros((n_output, n_hidden)), 'w2') self.w2 = shared(numpy.zeros((n_output, n_hidden)), 'w2')
print self.lr.type #print self.lr.type
self.hidden = sigmoid(tensor.dot(self.w1, self.input)) self.hidden = sigmoid(tensor.dot(self.w1, self.input))
self.output = tensor.dot(self.w2, self.hidden) self.output = tensor.dot(self.w2, self.hidden)
...@@ -51,7 +51,7 @@ class TestNnet(unittest.TestCase): ...@@ -51,7 +51,7 @@ class TestNnet(unittest.TestCase):
output, cost = nnet.sgd_step(input, target) output, cost = nnet.sgd_step(input, target)
mean_cost += cost mean_cost += cost
mean_cost /= float(len(data)) mean_cost /= float(len(data))
print 'Mean cost at epoch %s: %s' % (epoch, mean_cost) #print 'Mean cost at epoch %s: %s' % (epoch, mean_cost)
self.assertTrue(abs(mean_cost - 0.20588975452) < 1e-6) self.assertTrue(abs(mean_cost - 0.20588975452) < 1e-6)
# Just call functions to make sure they do not crash. # Just call functions to make sure they do not crash.
out = nnet.compute_output(input) out = nnet.compute_output(input)
......
...@@ -146,7 +146,7 @@ class T_module(unittest.TestCase): ...@@ -146,7 +146,7 @@ class T_module(unittest.TestCase):
#assign 4 and 5 to the two variables' containers in m #assign 4 and 5 to the two variables' containers in m
m.l = [4, 5] m.l = [4, 5]
print 'm.f', m.f() m.f()
assert numpy.all(5 == m.f()) assert numpy.all(5 == m.f())
assert numpy.all(4 == m.g()) assert numpy.all(4 == m.g())
...@@ -189,9 +189,9 @@ class T_module(unittest.TestCase): ...@@ -189,9 +189,9 @@ class T_module(unittest.TestCase):
assert 5 == m.f() assert 5 == m.f()
assert 4 == m.g() assert 4 == m.g()
print 'dscalar test' #print 'dscalar test'
local_test(lambda:T.dscalar(),lambda:T.dscalar()) local_test(lambda:T.dscalar(),lambda:T.dscalar())
print 'value test' #print 'value test'
local_test(lambda:T.value(1),lambda:T.value(2)) local_test(lambda:T.value(1),lambda:T.value(2))
...@@ -494,9 +494,9 @@ class T_module(unittest.TestCase): ...@@ -494,9 +494,9 @@ class T_module(unittest.TestCase):
M.a = [1,2,3] M.a = [1,2,3]
M.make() M.make()
m = M.make() m = M.make()
print m.a #print m.a
print m.a[0], type(m.a[0]), m.a[0] == 1 #print m.a[0], type(m.a[0]), m.a[0] == 1
print list(m.a) #print list(m.a)
assert list(m.a) == [1,2,3] assert list(m.a) == [1,2,3]
assert m.a is not M.a assert m.a is not M.a
try: try:
...@@ -545,7 +545,8 @@ def test_multiple_references(): ...@@ -545,7 +545,8 @@ def test_multiple_references():
self.sub_module = sub_module self.sub_module = sub_module
def _instance_initialize(self, obj): def _instance_initialize(self, obj):
print 'Initializing A' pass
#print 'Initializing A'
class B(theano.Module): class B(theano.Module):
...@@ -555,7 +556,8 @@ def test_multiple_references(): ...@@ -555,7 +556,8 @@ def test_multiple_references():
self.sub_module = sub_module self.sub_module = sub_module
def _instance_initialize(self, obj): def _instance_initialize(self, obj):
print 'Initializing B' pass
#print 'Initializing B'
class C(theano.Module): class C(theano.Module):
...@@ -565,11 +567,11 @@ def test_multiple_references(): ...@@ -565,11 +567,11 @@ def test_multiple_references():
self.value = theano.tensor.scalar() self.value = theano.tensor.scalar()
def _instance_initialize(self, obj): def _instance_initialize(self, obj):
print 'Initializing C' #print 'Initializing C'
obj.value = 0 obj.value = 0
def _instance_set(self, obj, value): def _instance_set(self, obj, value):
print 'Setting C' #print 'Setting C'
obj.value = value obj.value = value
...@@ -584,7 +586,7 @@ def test_multiple_references(): ...@@ -584,7 +586,7 @@ def test_multiple_references():
self.bug = theano.tensor.scalar() self.bug = theano.tensor.scalar()
def _instance_initialize(self, obj): def _instance_initialize(self, obj):
print 'Initializing D' #print 'Initializing D'
obj.c.set(1) obj.c.set(1)
......
...@@ -369,7 +369,6 @@ class Test_pfunc(unittest.TestCase): ...@@ -369,7 +369,6 @@ class Test_pfunc(unittest.TestCase):
z: (((x * 5) + y) ** z)}) z: (((x * 5) + y) ** z)})
up() up()
print x.get_value(borrow=True)
assert numpy.all(x.get_value() == 20) assert numpy.all(x.get_value() == 20)
assert numpy.all(y.get_value() == 24) assert numpy.all(y.get_value() == 24)
assert numpy.all(z.get_value() == (24 ** 2)) assert numpy.all(z.get_value() == (24 ** 2))
...@@ -380,7 +379,6 @@ class Test_pfunc(unittest.TestCase): ...@@ -380,7 +379,6 @@ class Test_pfunc(unittest.TestCase):
f = pfunc([], [x]) f = pfunc([], [x])
f() f()
print x.get_value()
assert x.get_value() == 1 assert x.get_value() == 1
del x.default_update del x.default_update
...@@ -399,32 +397,26 @@ class Test_pfunc(unittest.TestCase): ...@@ -399,32 +397,26 @@ class Test_pfunc(unittest.TestCase):
# Test that the default update is taken into account in the right cases # Test that the default update is taken into account in the right cases
f1 = pfunc([], [x], no_default_updates=True) f1 = pfunc([], [x], no_default_updates=True)
f1() f1()
print x.get_value()
assert x.get_value() == 0 assert x.get_value() == 0
f2 = pfunc([], [x], no_default_updates=[x]) f2 = pfunc([], [x], no_default_updates=[x])
f2() f2()
print x.get_value()
assert x.get_value() == 0 assert x.get_value() == 0
f3 = pfunc([], [x], no_default_updates=[x, y]) f3 = pfunc([], [x], no_default_updates=[x, y])
f3() f3()
print x.get_value()
assert x.get_value() == 0 assert x.get_value() == 0
f4 = pfunc([], [x], no_default_updates=[y]) f4 = pfunc([], [x], no_default_updates=[y])
f4() f4()
print x.get_value()
assert x.get_value() == 2 assert x.get_value() == 2
f5 = pfunc([], [x], no_default_updates=[]) f5 = pfunc([], [x], no_default_updates=[])
f5() f5()
print x.get_value()
assert x.get_value() == 4 assert x.get_value() == 4
f5 = pfunc([], [x], no_default_updates=False) f5 = pfunc([], [x], no_default_updates=False)
f5() f5()
print x.get_value()
assert x.get_value() == 6 assert x.get_value() == 6
self.assertRaises(TypeError, pfunc, [], [x], no_default_updates=(x)) self.assertRaises(TypeError, pfunc, [], [x], no_default_updates=(x))
...@@ -435,32 +427,26 @@ class Test_pfunc(unittest.TestCase): ...@@ -435,32 +427,26 @@ class Test_pfunc(unittest.TestCase):
# Mix explicit updates and no_default_updates # Mix explicit updates and no_default_updates
g1 = pfunc([], [x], updates=[(x, (x - 1))], no_default_updates=True) g1 = pfunc([], [x], updates=[(x, (x - 1))], no_default_updates=True)
g1() g1()
print x.get_value()
assert x.get_value() == 5 assert x.get_value() == 5
g2 = pfunc([], [x], updates=[(x, (x - 1))], no_default_updates=[x]) g2 = pfunc([], [x], updates=[(x, (x - 1))], no_default_updates=[x])
g2() g2()
print x.get_value()
assert x.get_value() == 4 assert x.get_value() == 4
g3 = pfunc([], [x], updates=[(x, (x - 1))], no_default_updates=[x, y]) g3 = pfunc([], [x], updates=[(x, (x - 1))], no_default_updates=[x, y])
g3() g3()
print x.get_value()
assert x.get_value() == 3 assert x.get_value() == 3
g4 = pfunc([], [x], updates=[(x, (x - 1))], no_default_updates=[y]) g4 = pfunc([], [x], updates=[(x, (x - 1))], no_default_updates=[y])
g4() g4()
print x.get_value()
assert x.get_value() == 2 assert x.get_value() == 2
g5 = pfunc([], [x], updates=[(x, (x - 1))], no_default_updates=[]) g5 = pfunc([], [x], updates=[(x, (x - 1))], no_default_updates=[])
g5() g5()
print x.get_value()
assert x.get_value() == 1 assert x.get_value() == 1
g5 = pfunc([], [x], updates=[(x, (x - 1))], no_default_updates=False) g5 = pfunc([], [x], updates=[(x, (x - 1))], no_default_updates=False)
g5() g5()
print x.get_value()
assert x.get_value() == 0 assert x.get_value() == 0
def test_default_updates_expressions(self): def test_default_updates_expressions(self):
...@@ -473,17 +459,14 @@ class Test_pfunc(unittest.TestCase): ...@@ -473,17 +459,14 @@ class Test_pfunc(unittest.TestCase):
f1 = pfunc([a], z) f1 = pfunc([a], z)
f1(12) f1(12)
print x
assert x.get_value() == 1 assert x.get_value() == 1
f2 = pfunc([a], z, no_default_updates=True) f2 = pfunc([a], z, no_default_updates=True)
assert f2(7) == 7 assert f2(7) == 7
print x
assert x.get_value() == 1 assert x.get_value() == 1
f3 = pfunc([a], z, no_default_updates=[x]) f3 = pfunc([a], z, no_default_updates=[x])
assert f3(9) == 9 assert f3(9) == 9
print x
assert x.get_value() == 1 assert x.get_value() == 1
def test_default_updates_multiple(self): def test_default_updates_multiple(self):
...@@ -524,7 +507,6 @@ class Test_pfunc(unittest.TestCase): ...@@ -524,7 +507,6 @@ class Test_pfunc(unittest.TestCase):
f1 = pfunc([], [x]) f1 = pfunc([], [x])
f1() f1()
print x.get_value(), y.get_value(), z.get_value()
assert x.get_value() == 1 assert x.get_value() == 1
assert y.get_value() == -1 assert y.get_value() == -1
assert z.get_value() == -2 assert z.get_value() == -2
...@@ -598,10 +580,8 @@ class Test_pfunc(unittest.TestCase): ...@@ -598,10 +580,8 @@ class Test_pfunc(unittest.TestCase):
b = 2 * a b = 2 * a
# Use only the tip of the graph, a is not used # Use only the tip of the graph, a is not used
f = pfunc([b], b) f = pfunc([b], b)
print 'a.get_value() =', a.get_value()
assert a.get_value() == 0 assert a.get_value() == 0
f(21) f(21)
print 'a.get_value() =', a.get_value()
assert a.get_value() == 0 assert a.get_value() == 0
def test_givens_replaces_shared_variable(self): def test_givens_replaces_shared_variable(self):
...@@ -917,7 +897,7 @@ class Test_aliasing_rules(unittest.TestCase): ...@@ -917,7 +897,7 @@ class Test_aliasing_rules(unittest.TestCase):
data_of_b = data_of(B) data_of_b = data_of(B)
f = pfunc([], [], updates=[(A, B[:, ::-1]), (B, A.T)]) f = pfunc([], [], updates=[(A, B[:, ::-1]), (B, A.T)])
theano.printing.debugprint(f) #theano.printing.debugprint(f)
f() f()
# correctness (doesn't actually test the view...) # correctness (doesn't actually test the view...)
assert numpy.all(data_of(A) == -.5) assert numpy.all(data_of(A) == -.5)
...@@ -938,7 +918,6 @@ class Test_aliasing_rules(unittest.TestCase): ...@@ -938,7 +918,6 @@ class Test_aliasing_rules(unittest.TestCase):
assert numpy.all(data_of(B) < 5) assert numpy.all(data_of(B) < 5)
data_of_a += 10 data_of_a += 10
print data_of(B)
assert numpy.all(data_of(B) > 5) assert numpy.all(data_of(B) > 5)
data_of_a -= 10 data_of_a -= 10
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论