def setUp(self): self.prob = np.arange(0, 1.01, 0.01) rate = dcs.prob_to_rate(self.prob, time=1./12) mult_rate_2 = rate * 2 mult_rate_half = rate * 0.5 self.mult_prob_2 = dcs.rate_to_prob(mult_rate_2, time=1./12) self.mult_prob_half = dcs.rate_to_prob(mult_rate_half, time=1./12)
def setUp(self): self.prob = np.arange(0, 1.01, 0.01) rate = dcs.prob_to_rate(self.prob, time=1. / 12) mult_rate_2 = rate * 2 mult_rate_half = rate * 0.5 self.mult_prob_2 = dcs.rate_to_prob(mult_rate_2, time=1. / 12) self.mult_prob_half = dcs.rate_to_prob(mult_rate_half, time=1. / 12)
def test_prob_rate_conversions3b(self): new = dcs.Units.convert(0.5, dcs.Units.AR, dcs.Units.AP) exp = dcs.rate_to_prob(0.5) self.assertEqual(new, exp)
def test_prob_rate_conversions3b(self): new = dcs.Units.convert(0.5, dcs.Units.AR, dcs.Units.AP) exp = dcs.rate_to_prob(0.5) self.assertEqual(new, exp)
def test_circular(self): rate = dcs.monthly_probability_to_annual_rate(self.prob) np.testing.assert_array_almost_equal(rate, self.rate) prob = dcs.rate_to_prob(rate) np.testing.assert_array_almost_equal(prob, self.prob)
def test_circular(self): prob = dcs.rate_to_prob(self.rate, self.time) np.testing.assert_array_almost_equal(prob, self.prob) rate = dcs.prob_to_rate(prob, self.time) np.testing.assert_array_almost_equal(rate, self.rate)
def test_infinity(self): prob = dcs.rate_to_prob(np.inf) self.assertAlmostEqual(prob, 1.)
def test_lt_zero(self): with self.assertRaises(ValueError): dcs.rate_to_prob(np.array([0., 0.5, -1.]))
def test_scalar(self): prob = dcs.rate_to_prob(0) self.assertIn(prob, self.prob)
def test_conversion(self): prob = dcs.rate_to_prob(self.rate, self.time) np.testing.assert_array_almost_equal(prob, self.prob)
def test_circular(self): rate = dcs.monthly_probability_to_annual_rate(self.prob) np.testing.assert_array_almost_equal(rate, self.rate) prob = dcs.rate_to_prob(rate) np.testing.assert_array_almost_equal(prob, self.prob)
def test_circular(self): prob = dcs.rate_to_prob(self.rate, self.time) np.testing.assert_array_almost_equal(prob, self.prob) rate = dcs.prob_to_rate(prob, self.time) np.testing.assert_array_almost_equal(rate, self.rate)
def test_infinity(self): prob = dcs.rate_to_prob(np.inf) self.assertAlmostEqual(prob, 1.)
def test_lt_zero(self): with self.assertRaises(ValueError): dcs.rate_to_prob(np.array([0., 0.5, -1.]))
def test_scalar(self): prob = dcs.rate_to_prob(0) self.assertIn(prob, self.prob)
def test_conversion(self): prob = dcs.rate_to_prob(self.rate, self.time) np.testing.assert_array_almost_equal(prob, self.prob)