예제 #1
0
    def testBoundValue(self):
        d = TierConverter( self.tier )
        p,q = d.bounds_to_vector( self.tier )
        print "\n Vector p:",p
        print "\n Vector q:",q

        k = Kappa(p,q)
        self.assertTrue(k.check_vector(p))
        self.assertTrue(k.check_vector(q))
        self.assertTrue(k.check()) # check both p and q
        self.assertEqual(k.evaluate(), 1.)

        othertier = Tier()
        othertier.Append(self.x)
        othertier.Append(self.y)
        othertier.Append(self.b)
        p,q = d.bounds_to_vector( othertier )
        print "\n Vector p:",p
        print "\n Vector q:",q

        kb = Kappa(p,q)
        self.assertTrue(kb.check_vector(p))
        self.assertTrue(kb.check_vector(q))
        self.assertTrue(kb.check()) # check both p and q
        self.assertEqual(kb.evaluate(), 0.)
예제 #2
0
 def testkappa(self):
     kappa = Kappa(self.p,self.q)
     self.assertTrue(kappa.check_vector(self.p))
     self.assertTrue(kappa.check_vector(self.q))
     self.assertTrue(kappa.check()) # check both p and q
     self.assertFalse(kappa.check_vector([ (0.,1.) , (0.,1.,0.) ]))
     self.assertFalse(kappa.check_vector([ (0.0,0.1) ]))
     v = kappa.evaluate()
     self.assertEqual(0.54545, round(v,5))
예제 #3
0
    def testLabelValue(self):
        d = TierConverter( self.tier )
        items1 = d.tier_to_items( )
        items2 = d.tier_to_items( ) # ... !!! with same tier, expect kappa=1
        items = sorted(list(set(items1+items2)))

        p = d.labels_to_vector( items )
        q = d.labels_to_vector( items )

        k = Kappa(p,q)
        self.assertTrue(k.check_vector(p))
        self.assertTrue(k.check_vector(q))
        self.assertTrue(k.check()) # check both p and q
        self.assertEqual(k.evaluate(), 1.)