def test_logyxlinear(self): yy = [x * .5 for x in self.x] log_yy = [-log(y) / x for x, y in zip(self.x, yy)] lin = linear(self.x, log_yy) loglin = loglinearrate(self.x, yy) for w in [0.25]: for x in self.s: x = 0.01 + x * w self.assertAlmostEqual(loglin(x), exp(-lin(x) * x))
def test_update(self): f = linear(self.x, self.y) for s in self.s: if s in self.x: self.assertTrue(s in f) else: self.assertFalse(s in f) y = [f(s) for s in reversed(self.s)] ff = no() ff._update(self.s, y) for s in self.s: self.assertTrue(s in ff) for s, e in zip(ff.x_list[:1], ff.x_list[1:]): self.assertTrue(s < e) for s in self.s: self.assertTrue(s in ff) ff._update([s]) self.assertFalse(s in ff)
def test_linear(self): f = linear(self.x, self.y) for x in [0.] + self.x: for s in self.s: self.assertAlmostEqual(f(x + s), self.a + self.b * (x + s))