提交 9a539c65 authored 作者: Ian Goodfellow's avatar Ian Goodfellow

removed tests of the Value class

changed most tests that rely on the Value class to use Constant or shared instead
上级 5d1b70a1
...@@ -22,7 +22,7 @@ class T_module(unittest.TestCase): ...@@ -22,7 +22,7 @@ class T_module(unittest.TestCase):
class Blah(Module): class Blah(Module):
def __init__(self, stepsize): def __init__(self, stepsize):
super(Blah, self).__init__() super(Blah, self).__init__()
self.stepsize = T.value(stepsize) self.stepsize = T.constant(stepsize)
x = T.dscalar() x = T.dscalar()
self.step = Method([x], x - self.stepsize) self.step = Method([x], x - self.stepsize)
...@@ -128,7 +128,7 @@ class T_module(unittest.TestCase): ...@@ -128,7 +128,7 @@ class T_module(unittest.TestCase):
assert i[0]==j assert i[0]==j
local_test(lambda:T.dscalar(),lambda:T.dscalar()) local_test(lambda:T.dscalar(),lambda:T.dscalar())
local_test(lambda:T.value(1),lambda:T.value(2)) local_test(lambda:T.constant(1),lambda:T.constant(2))
local_test(lambda:T.constant(1),lambda:T.constant(2)) local_test(lambda:T.constant(1),lambda:T.constant(2))
def test_list_assign(self): def test_list_assign(self):
...@@ -151,7 +151,6 @@ class T_module(unittest.TestCase): ...@@ -151,7 +151,6 @@ class T_module(unittest.TestCase):
assert numpy.all(4 == m.g()) assert numpy.all(4 == m.g())
local_test(lambda:T.dscalar(),lambda:T.dscalar()) local_test(lambda:T.dscalar(),lambda:T.dscalar())
local_test(lambda:T.value(1),lambda:T.value(2))
def test_tuple_assign(self): def test_tuple_assign(self):
"""Test that list members can be assigned tuple-wise""" """Test that list members can be assigned tuple-wise"""
...@@ -170,7 +169,6 @@ class T_module(unittest.TestCase): ...@@ -170,7 +169,6 @@ class T_module(unittest.TestCase):
assert 4 == m.g() assert 4 == m.g()
local_test(lambda:T.dscalar(),lambda:T.dscalar()) local_test(lambda:T.dscalar(),lambda:T.dscalar())
local_test(lambda:T.value(1),lambda:T.value(2))
def test_dict_assign(self): def test_dict_assign(self):
"""Test that list members can be assigned dict-wise""" """Test that list members can be assigned dict-wise"""
...@@ -191,8 +189,6 @@ class T_module(unittest.TestCase): ...@@ -191,8 +189,6 @@ class T_module(unittest.TestCase):
#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'
local_test(lambda:T.value(1),lambda:T.value(2))
def test_method_in_list_or_dict(self): def test_method_in_list_or_dict(self):
...@@ -452,16 +448,6 @@ class T_module(unittest.TestCase): ...@@ -452,16 +448,6 @@ class T_module(unittest.TestCase):
assert numpy.all(m.f(xval) == [1, 2.5]) assert numpy.all(m.f(xval) == [1, 2.5])
assert numpy.all(xval == [-1, -1.5]) assert numpy.all(xval == [-1, -1.5])
def test_member_value(self):
"""Test that module Members of Value work correctly. As Variable?"""
M = Module()
x = T.dscalar()
M.y = T.value(40)
M.f = Method([x], x + 2 * M.y)
m = M.make()
m.y = 80
assert m.f(20) == 180
def test_member_constant(self): def test_member_constant(self):
"""Test that module Members of Constant work correctly. """Test that module Members of Constant work correctly.
As Variable with more optimization?""" As Variable with more optimization?"""
......
...@@ -34,8 +34,8 @@ class MyType(Type): ...@@ -34,8 +34,8 @@ class MyType(Type):
def MyVariable(name): def MyVariable(name):
return Variable(MyType(), None, None, name = name) return Variable(MyType(), None, None, name = name)
def MyValue(data): def MyConstant(data):
return graph.Value(MyType(), data = data) return graph.Constant(MyType(), data = data)
class MyOp(Op): class MyOp(Op):
...@@ -385,7 +385,7 @@ def test_value_repl(): ...@@ -385,7 +385,7 @@ def test_value_repl():
e = add_in_place(x, sy) e = add_in_place(x, sy)
g = Env([x,y], [e], False) g = Env([x,y], [e], False)
consistent(g) consistent(g)
g.replace(sy, MyValue("abc")) g.replace(sy, MyConstant("abc"))
consistent(g) consistent(g)
def test_value_repl_2(): def test_value_repl_2():
...@@ -394,7 +394,7 @@ def test_value_repl_2(): ...@@ -394,7 +394,7 @@ def test_value_repl_2():
e = add_in_place(x, sy) e = add_in_place(x, sy)
g = Env([x,y], [e], False) g = Env([x,y], [e], False)
consistent(g) consistent(g)
g.replace(sy, transpose_view(MyValue("abc"))) g.replace(sy, transpose_view(MyConstant("abc")))
consistent(g) consistent(g)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论