test_chebtech.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:chebpy 作者: chebpy 项目源码 文件源码
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.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号