Exemple #1
0
class CurveTest(unittest.TestCase):
    def setUp(self):
        self.data = Curve([(1,2), (3,4), (5,5), (7,0)])

    def test_get_interpolated_point(self):
        self.failUnless(self.data.get_interpolated_point(1)   ==   (1, 2))
        self.failUnless(self.data.get_interpolated_point(5)   ==   (5, 5))
        self.failUnless(self.data.get_interpolated_point(2)   ==   (2, 3))
        self.failUnless(self.data.get_interpolated_point(2.5) == (2.5, 3.5))
        self.failUnless(self.data.get_interpolated_point(0)   ==   (0, 1))
        self.failUnless(self.data.get_interpolated_point(-1)  ==  (-1, 0))
        self.failUnless(self.data.get_interpolated_point(9)   ==  (9, -5))

    def test_resample(self):
        self.data.resample([0, 2, 4, 6, 8])
        self.failUnless(self.data.points == \
             [(0, 1), (2, 3), (4, 4.5), (6, 2.5), (8, -2.5)]
        )
Exemple #2
0
 def test_auc_superclass(self):
     self.assertAlmostEquals(0.95, Curve.auc(self.curve), 8)
Exemple #3
0
 def setUp(self):
     self.data = Curve([(1,2), (3,4), (5,5), (7,0)])