Example #1
0
 def test_errors(self):
     def fake(x): raise Exception
     self.assertRaises(Exception,ex11.sum_functions(fake,abs),5)
     self.assertRaises(Exception,ex11.sub_functions(fake,abs),5)
     self.assertRaises(Exception,ex11.mul_functions(fake,abs),5)
     self.assertRaises(Exception,ex11.div_functions(fake,abs),5)
     self.assertRaises(Exception,ex11.compose(fake,abs),5)
     self.assertRaises(Exception,ex11.compose(abs,fake),5)
     self.assertRaises(Exception,ex11.inverse(fake),5)
     self.assertRaises(Exception,ex11.derivative(fake),5)
     self.assertRaises(Exception,ex11.integral_function(fake),5)
Example #2
0
 def test_errors(self):
     def fake(x): raise Exception
     self.assertRaises(Exception,ex11.sum_functions(fake,abs),5)
     self.assertRaises(Exception,ex11.sub_functions(fake,abs),5)
     self.assertRaises(Exception,ex11.mul_functions(fake,abs),5)
     self.assertRaises(Exception,ex11.div_functions(fake,abs),5)
     self.assertRaises(Exception,ex11.compose(fake,abs),5)
     self.assertRaises(Exception,ex11.compose(abs,fake),5)
     self.assertRaises(Exception,ex11.inverse(fake),5)
     self.assertRaises(Exception,ex11.derivative(fake),5)
     self.assertRaises(Exception,ex11.integral_function(fake),5)
Example #3
0
 def test_inverse2(self):
     f = ex11.inverse(lambda x: 2 * x, 1e-6)
     self.assertAlmostEqual(f(9), 4.5, delta=5 * 1e-6)
     self.assertAlmostEqual(f(-2), -1, delta=5 * 1e-6)
Example #4
0
 def test_inverse2(self):
     f = ex11.inverse(lambda x:2*x,1e-6)
     self.assertAlmostEqual(f(9),4.5,delta=5*1e-6)
     self.assertAlmostEqual(f(-2),-1,delta=5*1e-6)