Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #8
0
 def test_gt_one(self):
     with self.assertRaises(ValueError):
         dcs.prob_to_rate(np.array([0., 0.5, 1.5]))
Пример #9
0
 def test_lt_zero(self):
     with self.assertRaises(ValueError):
         dcs.prob_to_rate(np.array([0., 0.5, -1.]))
Пример #10
0
 def test_scalar(self):
     rate = dcs.prob_to_rate(0)
     self.assertIn(rate, self.rate)
Пример #11
0
 def test_conversion(self):
     rate = dcs.prob_to_rate(self.prob, self.time)
     np.testing.assert_array_almost_equal(rate, self.rate)
Пример #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)
Пример #13
0
 def test_gt_one(self):
     with self.assertRaises(ValueError):
         dcs.prob_to_rate(np.array([0., 0.5, 1.5]))
Пример #14
0
 def test_lt_zero(self):
     with self.assertRaises(ValueError):
         dcs.prob_to_rate(np.array([0., 0.5, -1.]))
Пример #15
0
 def test_scalar(self):
     rate = dcs.prob_to_rate(0)
     self.assertIn(rate, self.rate)
Пример #16
0
 def test_conversion(self):
     rate = dcs.prob_to_rate(self.prob, self.time)
     np.testing.assert_array_almost_equal(rate, self.rate)