dot, gemm, fixing tests

上级 eba4c188
...@@ -194,6 +194,7 @@ class T_subtensor(unittest.TestCase): ...@@ -194,6 +194,7 @@ class T_subtensor(unittest.TestCase):
t = n[0] t = n[0]
except ValueError, e: except ValueError, e:
self.failUnless(e[0] is Subtensor.e_invalid) self.failUnless(e[0] is Subtensor.e_invalid)
return
self.fail() self.fail()
def test1_err_bounds(self): def test1_err_bounds(self):
n = tinit(numpy.ones(3)) n = tinit(numpy.ones(3))
...@@ -372,6 +373,7 @@ class T_abs(unittest.TestCase): ...@@ -372,6 +373,7 @@ class T_abs(unittest.TestCase):
verify_grad(self, T_abs.AbsBadGrad, [numpy.ones(())]) verify_grad(self, T_abs.AbsBadGrad, [numpy.ones(())])
except Exception, e: except Exception, e:
self.failUnless(str(e) == verify_grad.E_grad, str(e)) self.failUnless(str(e) == verify_grad.E_grad, str(e))
return
self.fail() self.fail()
class T_fill(unittest.TestCase): class T_fill(unittest.TestCase):
...@@ -441,6 +443,7 @@ class T_mul(unittest.TestCase): ...@@ -441,6 +443,7 @@ class T_mul(unittest.TestCase):
[numpy.ones(3), numpy.ones(4)], 1.0) [numpy.ones(3), numpy.ones(4)], 1.0)
except ValueError, e: except ValueError, e:
self.failUnless(e[0] is tensor._assert_same_shapes.E_shape) self.failUnless(e[0] is tensor._assert_same_shapes.E_shape)
return
self.fail() self.fail()
class T_div(unittest.TestCase): class T_div(unittest.TestCase):
......
...@@ -4,10 +4,9 @@ def test_root_dir(): ...@@ -4,10 +4,9 @@ def test_root_dir():
suite = None suite = None
filenames = os.listdir('.') filenames = os.listdir('.')
for filename in filenames: for filename in filenames:
if filename[-3:] == '.py': if filename[-3:] == '.py' and filename[0:5] == '_test':
modname = filename[:-3]
if modname in ['__init__', 'autotest']: continue
#print >>sys.stderr, 'Loading', modname #print >>sys.stderr, 'Loading', modname
modname = filename[0:-3]
tests = unittest.TestLoader().loadTestsFromModule(__import__(modname)) tests = unittest.TestLoader().loadTestsFromModule(__import__(modname))
if tests.countTestCases() > 0: if tests.countTestCases() > 0:
print >>sys.stderr, 'Testing', modname print >>sys.stderr, 'Testing', modname
......
import os, sys import os, sys
from gof import PatternOptimizer as pattern_opt, OpSubOptimizer as op_sub
import scipy.weave as weave import scipy.weave as weave
""" """
......
from core import *
import gof
from gof import PatternOptimizer as pattern_opt, OpSubOptimizer as op_sub
""" """
This variable is used in compile.prog as the optimizer for all programs built This variable is used in compile.prog as the optimizer for all programs built
using either compile.single, compile.to_func, and compile.prog. using either compile.single, compile.to_func, and compile.prog.
"""
def optimizer(lst): if 0:
begin = gof.SeqOptimizer([]) def optimizer(lst):
end = gof.SeqOptimizer([gof.DummyRemover]) begin = gof.SeqOptimizer([])
seq_opt = gof.SeqOptimizer(begin + lst + end) end = gof.SeqOptimizer([gof.DummyRemover])
return gof.PythonOpt(gof.MergeOptMerge(seq_opt)) seq_opt = gof.SeqOptimizer(begin + lst + end)
return gof.PythonOpt(gof.MergeOptMerge(seq_opt))
if 0: if 0:
optimizer_begin = gof.SeqOptimizer([opt for name, opt in [ optimizer_begin = gof.SeqOptimizer([opt for name, opt in [
...@@ -34,3 +29,4 @@ if 0: ...@@ -34,3 +29,4 @@ if 0:
(iadd_elemwise, 'y', 'x'))]]]) (iadd_elemwise, 'y', 'x'))]]])
# ['remove_copies', gof.OpRemover(array_copy)], # ['remove_copies', gof.OpRemover(array_copy)],
# [None, gof.DummyRemover] # has to be at the end # [None, gof.DummyRemover] # has to be at the end
"""
...@@ -3,13 +3,11 @@ import unittest ...@@ -3,13 +3,11 @@ import unittest
import numpy import numpy
from scipy import sparse from scipy import sparse
import gof.lib import gof
import core
import grad
# Wrapper type # Wrapper type
class SparseR(core.ResultBase): class SparseR(gof.ResultBase):
""" """
Attribute: Attribute:
format - a subclass of sparse.spmatrix indicating self.data.__class__ format - a subclass of sparse.spmatrix indicating self.data.__class__
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论