def binaryOpTester(f, g, binop, nf, ng):
ff = Chebtech2.initfun_fixedlen(f, nf)
gg = Chebtech2.initfun_fixedlen(g, ng)
FG = lambda x: binop(f(x),g(x))
fg = binop(ff, gg)
def tester(self):
vscl = max([ff.vscale, gg.vscale])
lscl = max([ff.size, gg.size])
self.assertLessEqual(infnorm(fg(self.xx)-FG(self.xx)), 3*vscl*lscl*eps)
if binop is operator.mul:
# check simplify is not being called in __mul__
self.assertEqual(fg.size, ff.size+gg.size-1)
return tester
# note: defining __radd__(a,b) = operator.add(b,a) and feeding this into the
# test will not in fact test the __radd__ functionality of the class. These
# test need to be added manually to the class.
评论列表
文章目录