示例#1
0
        def helper(y1,y2):
            alphabet = ('A','B','')
            toy_alphabet = OrderedDict([('A',0),('B',1)])
            profile1= profile(y1,alphabet)
            profile2=profile(y2,alphabet)
            joint_prof = joint_profile(profile1, profile2)

            gamma = decoding.pair_gamma(y1,y2)
            self.assertTrue(np.isclose(gamma[0,0], joint_prof.prob_agree))
示例#2
0
        def helper(y1,y2):
            alphabet = ('A','B','')
            toy_alphabet = OrderedDict([('A',0),('B',1)])
            profile1= profile(y1,alphabet)
            profile2=profile(y2,alphabet)
            joint_prof = joint_profile(profile1, profile2)

            gamma = decoding.decoding_cy.pair_gamma_log(np.log(y1).astype(np.float64),np.log(y2).astype(np.float64))
            print('log(Z):',gamma[0,0],np.log(joint_prof.prob_agree))
            self.assertTrue(np.isclose(gamma[0,0], np.log(joint_prof.prob_agree)))
示例#3
0
        def helper(y1, y2):
            alphabet = ('A', 'B', '')
            toy_alphabet = OrderedDict([('A', 0), ('B', 1)])
            profile1 = poreover_profile(y1, alphabet)
            profile2 = poreover_profile(y2, alphabet)
            joint_prof = joint_profile(profile1, profile2)

            gamma = prefix_search.pair_gamma_log(np.log(y1), np.log(y2))
            print('log(Z):', gamma[0, 0], np.log(joint_prof.prob_agree))
            self.assertTrue(
                np.isclose(gamma[0, 0], np.log(joint_prof.prob_agree)))
示例#4
0
        def helper(y1,y2):
            alphabet = ('A','B','')
            toy_alphabet = OrderedDict([('A',0),('B',1)])

            profile1= profile(y1,alphabet)
            profile2=profile(y2,alphabet)
            joint_prof = joint_profile(profile1, profile2)

            top_label = joint_prof.top_label()
            search_top_label = decoding.pair_prefix_search(y1,y2,alphabet=toy_alphabet)
            return((top_label[0] == search_top_label[0]) and np.isclose(top_label[1] / joint_prof.prob_agree, search_top_label[1]))
示例#5
0
 def test_full_envelope(self):
     y1 = np.array([[0.8, 0.1, 0.1], [0.1, 0.3, 0.6], [0.7, 0.2, 0.1],
                    [0.1, 0.1, 0.8]])
     y2 = np.array([[0.7, 0.2, 0.1], [0.2, 0.3, 0.5], [0.7, 0.2, 0.1],
                    [0.05, 0.05, 0.9]])
     full_seq = decoding.decoding_cpp.cpp_beam_search_2d(np.log(y1),
                                                         np.log(y2),
                                                         alphabet_="AB")
     prof1 = poreover_profile(y1, ('A', 'B', ''))
     prof2 = poreover_profile(y2, ('A', 'B', ''))
     joint_prof = joint_profile(prof1, prof2)
     self.assertTrue(full_seq == joint_prof.top_label()[0])
示例#6
0
        def helper(y1, y2):
            alphabet = ('A', 'B', '')
            toy_alphabet = OrderedDict([('A', 0), ('B', 1)])

            profile1 = poreover_profile(y1, alphabet)
            profile2 = poreover_profile(y2, alphabet)
            joint_prof = joint_profile(profile1, profile2)

            top_label = joint_prof.top_label()
            search_top_label = prefix_search.pair_prefix_search_log_cy(
                np.log(y1), np.log(y2), alphabet=toy_alphabet)

            print(top_label[0], np.log(top_label[1] / joint_prof.prob_agree),
                  search_top_label[0], search_top_label[1])
            return ((top_label[0] == search_top_label[0]) and np.isclose(
                np.log(top_label[1] / joint_prof.prob_agree),
                search_top_label[1]))
示例#7
0
    def test_flipflop_same(self):
        alphabet_tuple = ('A', 'B', 'a', 'b')
        alphabet = "AB"

        y = np.array([[0.8, 0.1, 0.05, 0.05], [0.1, 0.3, 0.5, 0.1],
                      [0.7, 0.2, 0.05, 0.05], [0.1, 0.1, 0.2, 0.6]],
                     dtype=np.float32)

        prof = flipflop_profile(y, alphabet_tuple)
        joint_prof = joint_profile(prof, prof)
        result_1d = decoding.decoding_cpp.cpp_beam_search(
            np.log(y), alphabet_="AB", model_='ctc_flipflop')
        result_2d = decoding.decoding_cpp.cpp_beam_search_2d(
            np.log(y),
            np.log(y),
            alphabet_="AB",
            method_="row",
            model_='ctc_flipflop')
        self.assertTrue(result_1d == result_2d)