Ejemplo n.º 1
0
    def test_project(self):
        scale = leather.Temporal(date(2010, 1, 1), date(2014, 1, 1))

        self.assertAlmostEqual(scale.project(date(2011, 1, 1), 0, 20), 5, 1)
        self.assertAlmostEqual(scale.project(date(2012, 1, 1), 0, 20), 10, 1)
        self.assertAlmostEqual(scale.project(date(2009, 1, 1), 0, 20), -5, 1)

        scale = leather.Temporal(datetime(2010, 1, 1), datetime(2014, 1, 1))

        self.assertAlmostEqual(scale.project(datetime(2011, 1, 1), 0, 20), 5,
                               1)
        self.assertAlmostEqual(scale.project(datetime(2012, 1, 1), 0, 20), 10,
                               1)
        self.assertAlmostEqual(scale.project(datetime(2009, 1, 1), 0, 20), -5,
                               1)
    def test_contains(self):
        scale = leather.Temporal(date(2010, 1, 1), date(2014, 1, 1))

        self.assertTrue(scale.contains(date(2010, 1, 1)))
        self.assertTrue(scale.contains(date(2012, 6, 3)))
        self.assertTrue(scale.contains(date(2014, 1, 1)))
        self.assertFalse(scale.contains(date(2009, 12, 31)))
        self.assertFalse(scale.contains(date(2014, 1, 2)))
Ejemplo n.º 3
0
    def test_ticks(self):
        scale = leather.Temporal(date(2010, 1, 1), date(2014, 1, 1))

        ticks = scale.ticks()
        self.assertEqual(ticks[0], date(2010, 1, 1))
        self.assertEqual(ticks[-1], date(2014, 1, 1))
Ejemplo n.º 4
0
    def test_project_interval(self):
        scale = leather.Temporal(date(2010, 1, 1), date(2014, 1, 1))

        with self.assertRaises(NotImplementedError):
            scale.project_interval(date(2011, 1, 1), 0, 20)