def test_equal(self): coeffs = self.SAMPLE_COEFFS[1] f1 = pm_model.CapacityFunction(domain=(0, 100), coefficients=coeffs, high_order_first=True) f2 = pm_model.CapacityFunction(domain=(0, 100), coefficients=coeffs[::-1], high_order_first=False) self.assertTrue(f1, f2)
def test_repr(self): """ Make sure __repr__ has no syntax problem. """ coeffs = self.SAMPLE_COEFFS[1] f = pm_model.CapacityFunction(domain=(0, 100), coefficients=coeffs[::-1], high_order_first=False) self.assertIsInstance(str(f), str)
def test_linear(self): x = 15 coeffs = self.SAMPLE_COEFFS[0] expected = x * coeffs[0] + coeffs[1] f = pm_model.CapacityFunction(domain=(0, 100), coefficients=coeffs, high_order_first=True) self.assertEqual(expected, f.eval(x), 'Evaluated value of function is not equal expected.')
def test_square_low_order(self): x = 26 coeffs = self.SAMPLE_COEFFS[1] expected = x * x * coeffs[0] + x * coeffs[1] + coeffs[2] f = pm_model.CapacityFunction(domain=(0, 100), coefficients=coeffs[::-1], high_order_first=False) self.assertEqual(expected, f.eval(x), 'Evaluated value of function is not equal expected.')