Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 def test_prob_rate_conversions2c(self):
     new = dcs.Units.convert(0.5, dcs.Units.AP, dcs.Units.AR)
     exp = dcs.prob_to_rate(0.5)
     self.assertEqual(new, exp)
Exemplo n.º 4
0
 def test_prob_rate_conversions1c(self):
     new = dcs.Units.convert(0.5, dcs.Units.MP, dcs.Units.AR)
     exp = dcs.prob_to_rate(dcs.convert_monthly_to_annual_probability(0.5))
     self.assertEqual(new, exp)
Exemplo n.º 5
0
 def test_prob_rate_conversions2c(self):
     new = dcs.Units.convert(0.5, dcs.Units.AP, dcs.Units.AR)
     exp = dcs.prob_to_rate(0.5)
     self.assertEqual(new, exp)
Exemplo n.º 6
0
 def test_prob_rate_conversions1c(self):
     new = dcs.Units.convert(0.5, dcs.Units.MP, dcs.Units.AR)
     exp = dcs.prob_to_rate(dcs.convert_monthly_to_annual_probability(0.5))
     self.assertEqual(new, exp)
Exemplo n.º 7
0
 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)
Exemplo n.º 8
0
 def test_gt_one(self):
     with self.assertRaises(ValueError):
         dcs.prob_to_rate(np.array([0., 0.5, 1.5]))
Exemplo n.º 9
0
 def test_lt_zero(self):
     with self.assertRaises(ValueError):
         dcs.prob_to_rate(np.array([0., 0.5, -1.]))
Exemplo n.º 10
0
 def test_scalar(self):
     rate = dcs.prob_to_rate(0)
     self.assertIn(rate, self.rate)
Exemplo n.º 11
0
 def test_conversion(self):
     rate = dcs.prob_to_rate(self.prob, self.time)
     np.testing.assert_array_almost_equal(rate, self.rate)
Exemplo n.º 12
0
 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)
Exemplo n.º 13
0
 def test_gt_one(self):
     with self.assertRaises(ValueError):
         dcs.prob_to_rate(np.array([0., 0.5, 1.5]))
Exemplo n.º 14
0
 def test_lt_zero(self):
     with self.assertRaises(ValueError):
         dcs.prob_to_rate(np.array([0., 0.5, -1.]))
Exemplo n.º 15
0
 def test_scalar(self):
     rate = dcs.prob_to_rate(0)
     self.assertIn(rate, self.rate)
Exemplo n.º 16
0
 def test_conversion(self):
     rate = dcs.prob_to_rate(self.prob, self.time)
     np.testing.assert_array_almost_equal(rate, self.rate)