Ejemplo n.º 1
0
    def test_yearfrac_basis_1_sub_year(self):
        assert 11 / 365 == pytest.approx(
            yearfrac(date(2015, 4, 20), date(2015, 5, 1), basis=1))

        assert 11 / 366 == pytest.approx(
            yearfrac(date(2016, 4, 20), date(2016, 5, 1), basis=1))

        assert 316 / 366 == pytest.approx(
            yearfrac(date(2016, 2, 20), date(2017, 1, 1), basis=1))

        assert 61 / 366 == pytest.approx(
            yearfrac(date(2015, 12, 31), date(2016, 3, 1), basis=1))
Ejemplo n.º 2
0
    def test_yearfrac_basis_1_sub_year(self):
        assert 11 / 365 == pytest.approx(
            yearfrac(date(2015, 4, 20), date(2015, 5, 1), 1))

        assert 11 / 366 == pytest.approx(
            yearfrac(date(2016, 4, 20), date(2016, 5, 1), 1))

        assert 316 / 366 == pytest.approx(
            yearfrac(date(2016, 2, 20), date(2017, 1, 1), 1))

        assert 61 / 366 == pytest.approx(
            yearfrac(date(2015, 12, 31), date(2016, 3, 1), 1))
Ejemplo n.º 3
0
 def test_start_date_must_be_positive(self):
     with self.assertRaises(ValueError):
         yearfrac(-1, 0)
Ejemplo n.º 4
0
 def test_start_date_must_be_number(self):
     with self.assertRaises(TypeError):
         yearfrac('not a number', 1)
Ejemplo n.º 5
0
 def test_end_date_must_be_number(self):
     assert VALUE_ERROR == yearfrac(1, 'not a number')
Ejemplo n.º 6
0
 def test_yearfrac_basis_3(self):
     assert 7.304109589 == pytest.approx(
         yearfrac(date(2008, 1, 1), date(2015, 4, 20), 3))
Ejemplo n.º 7
0
 def test_end_date_must_be_positive(self):
     with pytest.raises(ValueError):
         yearfrac(0, -1)
Ejemplo n.º 8
0
 def test_yearfrac_basis_4(self):
     self.assertAlmostEqual(
         yearfrac(date(2008, 1, 1), date(2015, 4, 20), 4), 7.302777778)
Ejemplo n.º 9
0
 def test_end_date_must_be_number(self):
     with self.assertRaises(TypeError):
         yearfrac(1, 'not a number')
Ejemplo n.º 10
0
 def test_start_date_must_be_number(self):
     with self.assertRaises(TypeError):
         yearfrac('not a number', 1)
Ejemplo n.º 11
0
 def test_yearfrac_inverted(self):
     self.assertAlmostEqual(yearfrac(date(2015, 4, 20), date(2008, 1, 1)), yearfrac(date(2008, 1, 1), date(2015, 4, 20)))    
Ejemplo n.º 12
0
 def test_basis_must_be_between_0_and_4(self):
     assert NUM_ERROR == yearfrac(1, 2, 5)
Ejemplo n.º 13
0
 def test_end_date_must_be_positive(self):
     assert NUM_ERROR == yearfrac(0, -1)
Ejemplo n.º 14
0
 def test_start_date_must_be_positive(self):
     assert NUM_ERROR == yearfrac(-1, 0)
Ejemplo n.º 15
0
 def test_basis_must_be_between_0_and_4(self):
     with self.assertRaises(ValueError):
         yearfrac(1, 2, 5)
Ejemplo n.º 16
0
 def test_yearfrac_basis_2(self):
     self.assertAlmostEqual(
         yearfrac(date(2008, 1, 1), date(2015, 4, 20), 2), 7.405555556)
Ejemplo n.º 17
0
 def test_start_date_must_be_positive(self):
     with self.assertRaises(ValueError):
         yearfrac(-1, 0)
Ejemplo n.º 18
0
 def test_end_date_must_be_number(self):
     with pytest.raises(TypeError):
         yearfrac(1, 'not a number')
Ejemplo n.º 19
0
 def test_end_date_must_be_positive(self):
     with self.assertRaises(ValueError):
         yearfrac(0, -1)
Ejemplo n.º 20
0
 def test_yearfrac_basis_1(self):
     assert 7.299110198 == pytest.approx(
         yearfrac(date(2008, 1, 1), date(2015, 4, 20), 1))
Ejemplo n.º 21
0
 def test_basis_must_be_between_0_and_4(self):
     with self.assertRaises(ValueError):
         yearfrac(1, 2, 5)
Ejemplo n.º 22
0
 def test_yearfrac_inverted(self):
     assert yearfrac(date(2008, 1, 1), date(2015, 4, 20)) == pytest.approx(
         yearfrac(date(2015, 4, 20), date(2008, 1, 1)))
Ejemplo n.º 23
0
 def test_yearfrac_basis_0(self):
     self.assertAlmostEqual(yearfrac(date(2008, 1, 1), date(2015, 4, 20)), 7.30277777777778)
Ejemplo n.º 24
0
 def test_yearfrac_inverted(self):
     assert yearfrac(date(2008, 1, 1), date(2015, 4, 20)) == pytest.approx(
         yearfrac(date(2015, 4, 20), date(2008, 1, 1)))
Ejemplo n.º 25
0
 def test_yearfrac_basis_1(self):
     self.assertAlmostEqual(yearfrac(date(2008, 1, 1), date(2015, 4, 20), 1), 7.299110198)
Ejemplo n.º 26
0
 def test_yearfrac_inverted(self):
     self.assertAlmostEqual(yearfrac(date(2015, 4, 20), date(2008, 1, 1)),
                            yearfrac(date(2008, 1, 1), date(2015, 4, 20)))
Ejemplo n.º 27
0
 def test_yearfrac_basis_2(self):
     self.assertAlmostEqual(yearfrac(date(2008, 1, 1), date(2015, 4, 20), 2), 7.405555556)
Ejemplo n.º 28
0
 def test_end_date_must_be_number(self):
     with self.assertRaises(TypeError):
         yearfrac(1, 'not a number')
Ejemplo n.º 29
0
 def test_yearfrac_basis_3(self):
     self.assertAlmostEqual(yearfrac(date(2008, 1, 1), date(2015, 4, 20), 3), 7.304109589)
Ejemplo n.º 30
0
 def test_end_date_must_be_positive(self):
     with self.assertRaises(ValueError):
         yearfrac(0, -1)
Ejemplo n.º 31
0
 def test_start_date_must_be_number(self):
     assert VALUE_ERROR == yearfrac('not a number', 1)
Ejemplo n.º 32
0
 def test_yearfrac_basis_1(self):
     self.assertAlmostEqual(
         yearfrac(date(2008, 1, 1), date(2015, 4, 20), 1), 7.299110198)
Ejemplo n.º 33
0
 def test_end_date_must_be_number(self):
     assert VALUE_ERROR == yearfrac(1, 'not a number')
Ejemplo n.º 34
0
 def test_yearfrac_basis_3(self):
     self.assertAlmostEqual(
         yearfrac(date(2008, 1, 1), date(2015, 4, 20), 3), 7.304109589)
Ejemplo n.º 35
0
 def test_start_date_must_be_positive(self):
     assert NUM_ERROR == yearfrac(-1, 0)
Ejemplo n.º 36
0
 def test_start_date_must_be_number(self):
     with pytest.raises(TypeError):
         yearfrac('not a number', 1)
Ejemplo n.º 37
0
 def test_end_date_must_be_positive(self):
     assert NUM_ERROR == yearfrac(0, -1)
Ejemplo n.º 38
0
 def test_start_date_must_be_positive(self):
     with pytest.raises(ValueError):
         yearfrac(-1, 0)
Ejemplo n.º 39
0
 def test_basis_must_be_between_0_and_4(self):
     assert NUM_ERROR == yearfrac(1, 2, 5)
Ejemplo n.º 40
0
 def test_basis_must_be_between_0_and_4(self):
     with pytest.raises(ValueError):
         yearfrac(1, 2, 5)
Ejemplo n.º 41
0
 def test_yearfrac_basis_1(self):
     assert 7.299110198 == pytest.approx(
         yearfrac(date(2008, 1, 1), date(2015, 4, 20), 1))
Ejemplo n.º 42
0
 def test_yearfrac_basis_2(self):
     assert 7.405555556 == pytest.approx(
         yearfrac(date(2008, 1, 1), date(2015, 4, 20), 2))
Ejemplo n.º 43
0
 def test_yearfrac_basis_2(self):
     assert 7.405555556 == pytest.approx(
         yearfrac(date(2008, 1, 1), date(2015, 4, 20), 2))
Ejemplo n.º 44
0
 def test_yearfrac_basis_4(self):
     assert 7.302777778 == pytest.approx(
         yearfrac(date(2008, 1, 1), date(2015, 4, 20), 4))
Ejemplo n.º 45
0
 def test_yearfrac_basis_3(self):
     assert 7.304109589 == pytest.approx(
         yearfrac(date(2008, 1, 1), date(2015, 4, 20), 3))
Ejemplo n.º 46
0
 def test_yearfrac_basis_4(self):
     assert 7.302777778 == pytest.approx(
         yearfrac(date(2008, 1, 1), date(2015, 4, 20), 4))
Ejemplo n.º 47
0
 def test_start_date_must_be_number(self):
     assert VALUE_ERROR == yearfrac('not a number', 1)