def test_good_case3(self): s = r''' 0 1 0 0 0 2 -1 0 1 2 -1 0 2 ''' fsa = k2host.str_to_fsa(s) self.assertTrue(k2host.is_valid(fsa))
def test_good_case2(self): s = r''' 0 1 0 0 0 2 0 0 2 3 -1 0 3 ''' fsa = k2host.str_to_fsa(s) self.assertTrue(k2host.is_valid(fsa))
def test_bad_case2(self): # only kFinalSymbol arcs enter the final state s = r''' 0 1 0 0 0 2 1 0 1 2 0 0 2 ''' fsa = k2host.str_to_fsa(s) self.assertFalse(k2host.is_valid(fsa))
def test_good_cases1(self): # empty fsa is valid array_size = k2host.IntArray2Size(0, 0) fsa = k2host.Fsa.create_fsa_with_size(array_size) self.assertTrue(k2host.is_valid(fsa))
def test_bad_case3(self): # `arc_indexes` and `arcs` in this state are not consistent arc_indexes = torch.IntTensor([0, 2, 2, 2]) arcs = torch.IntTensor([[0, 1, 0, 0], [0, 2, 1, 0], [1, 2, 0, 0]]) fsa = k2host.Fsa(arc_indexes, arcs) self.assertFalse(k2host.is_valid(fsa))
def test_bad_case1(self): # fsa should contain at least two states array_size = k2host.IntArray2Size(1, 0) fsa = k2host.Fsa.create_fsa_with_size(array_size) self.assertFalse(k2host.is_valid(fsa))