test_AFW.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:PySimpleAutomata 作者: Oneiroe 项目源码 文件源码
def test_afw_to_nfa_conversion_language_bis(self):
        """ Test a correct afw conversion to nfa comparing the language read 
        by the two automaton.
            Here we take a nfa, we covert it to afw and back to nfa,
            then the original and final nfa are compared trough the language 
            read.
        """
        original_nfa_to_afw = AFW.nfa_to_afw_conversion(
            self.nfa_afw_to_nfa_test_01)
        nfa_01 = AFW.afw_to_nfa_conversion(original_nfa_to_afw)
        i = 0
        last = 7
        while i <= last:
            base = list(itertools.repeat('a', i))
            base += list(itertools.repeat('b', i))
            # build all permutation of 'a' and 'b' till length i
            word_set = set(itertools.permutations(base, i))
            for word in word_set:
                word = list(word)
                # print(word)
                original_nfa_acceptance = NFA.nfa_word_acceptance(
                    self.nfa_afw_to_nfa_test_01, word)
                nfa_acceptance = NFA.nfa_word_acceptance(nfa_01, word)
                self.assertEqual(original_nfa_acceptance, nfa_acceptance)
            i += 1
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号