class TestPrototypeHMM(_BaseTest):
    def setUp(self):
        super(TestPrototypeHMM,self).setUp()
        self.p = PrototypeHMM(self.label, 
                              num_states=0.5, 
                              self_transprob=0.8, 
                              next_transprob=0.2, 
                              skip_transprob=1e-6)
        self.p.train(self.ink_data, max_N=15)
        
    def test_serialization(self):
        p_data = self.p.toJSON()
        q = PrototypeHMM(None)
        q.fromJSON(p_data)
        self.assertEqual(p_data, q.toJSON())

    def test_score(self):
        score0 = self.p.score(self.ink_data[0])
        self.assertAlmostEqual(score0, 47.772, delta=1e-3)
        score1 = self.p.score(self.ink_data[1])
        self.assertAlmostEqual(score1, 53.725, delta=1e-3)
 def test_serialization(self):
     p_data = self.p.toJSON()
     q = PrototypeHMM(None)
     q.fromJSON(p_data)
     self.assertEqual(p_data, q.toJSON())