コード例 #1
0
    def test_example_four_transitions(self):
        strike3_ssrcalcwindow = 1.0
        ssrcalcvalues  = self.ssrcalcvalues_four_example  
        
        N = [len(v) for v in ssrcalcvalues]
        res = thisthirdstrike(N, ssrcalcvalues, strike3_ssrcalcwindow)
        newdic = dict([(i,list(v)) for i,v in enumerate(res)])
        expanded = uis_functions.get_nonuis_list(newdic, 5)

        # There are five combinations of length 2 that are not eUIS: 
        #   (0,1), (0,2), (0,3), (1,2) and (1,3)
        # There are two combinations of length 3 that are not eUIS: 
        #   (0,1,3), (0,1,2)
        self.assertEqual(len(expanded[2]), 5 )
        self.assertEqual(len(expanded[3]), 2 )
        self.assertEqual(len(expanded[4]), 0 )

        self.assertTrue((0,1) in expanded[2])
        self.assertTrue((0,2) in expanded[2])
        self.assertTrue((0,3) in expanded[2])
        self.assertTrue((1,2) in expanded[2])
        self.assertTrue((1,3) in expanded[2])

        self.assertTrue((0,1,3) in expanded[3])
        self.assertTrue((0,1,2) in expanded[3])
コード例 #2
0
    def test_example_tworows_larger_window(self):
        # So with 1.0 we find that 2.5 - 1.9 = 0.6 is close enough
        strike3_ssrcalcwindow = 1.0
        ssrcalcvalues = self.ssrcalcvalues_two_example
        N = [len(v) for v in ssrcalcvalues]
        res = thisthirdstrike(N, ssrcalcvalues, strike3_ssrcalcwindow)
        newdic = dict([(i,list(v)) for i,v in enumerate(res)])
        expanded = uis_functions.get_nonuis_list(newdic, 2)

        self.assertEqual(len(expanded[2]), 1 )
コード例 #3
0
    def test_cpp_implementation(self):
        strike3_ssrcalcwindow = 0.3
        ssrcalcvalues  = self.ssrcalcvalues_four_example  
        N = [len(v) for v in ssrcalcvalues]

        cpp_result = c_getnonuis.calculate_eUIS(N, ssrcalcvalues, strike3_ssrcalcwindow)
        python_result = thisthirdstrike(N, ssrcalcvalues, strike3_ssrcalcwindow)
        cpp_result_compare = {}
        for c in cpp_result:
            cpp_result_compare[ tuple(c)] = 0
        self.assertEqual(cpp_result_compare, python_result)

        #print "second cpp impl"
        strike3_ssrcalcwindow = 1.0
        cpp_result = c_getnonuis.calculate_eUIS(N, ssrcalcvalues, strike3_ssrcalcwindow)
        python_result = thisthirdstrike(N, ssrcalcvalues, strike3_ssrcalcwindow)
        cpp_result_compare = {}
        for c in cpp_result:
            cpp_result_compare[ tuple(c)] = 0
        self.assertEqual(cpp_result_compare, python_result)
コード例 #4
0
    def test_example_four_transitions_small_window(self):
        strike3_ssrcalcwindow = 0.3
        ssrcalcvalues  = self.ssrcalcvalues_four_example  
        
        N = [len(v) for v in ssrcalcvalues]
        res = thisthirdstrike(N, ssrcalcvalues, strike3_ssrcalcwindow)
        newdic = dict([(i,list(v)) for i,v in enumerate(res)])
        expanded = uis_functions.get_nonuis_list(newdic, 5)

        # Now we loose (1,3) because 1.5 and 1.0 is too big a distance
        self.assertEqual(len(expanded[2]), 4 )
        self.assertEqual(len(expanded[3]), 1 )
        self.assertEqual(len(expanded[4]), 0 )

        self.assertTrue((1,3) not in expanded[2])
        self.assertTrue((0,1,2) in expanded[3])
コード例 #5
0
        ssrcalc = myprecursors.lookup_by_transition_group(k).ssrcalc
        for tr in v:
            ssrcalcvalues[tr].append(ssrcalc)

    # then sort the ssrcalc values 
    # complexity: nr_tr * k * log(k) 
    for i in range(len(ssrcalcvalues)):
        ssrcalcvalues[i] = sorted(ssrcalcvalues[i])

    # get the list of combinations that are not eUIS
    N = [len(v) for v in ssrcalcvalues]
    cont_comb_list = c_getnonuis.calculate_eUIS(N, ssrcalcvalues, strike3_ssrcalcwindow)
    
    if False:
        #compare c++/python code
        compare = thisthirdstrike(N, ssrcalcvalues, strike3_ssrcalcwindow)
        cont3 = {}
        for c in cont_comb_list:
            cont3[ tuple(c)] = 0
        assert compare == cont3

    # the list of combinations has to be expanded for a specific order (e.g.
    # for order 2, a combination of (1,2,3) has to be expanded into
    # (1,2),(1,3),(2,3) to get all subcombinations.
    newdic = dict([(i,list(v)) for i,v in enumerate(cont_comb_list)])
    non_useable_combinations.update(c_getnonuis.get_non_uis( newdic, myorder))

    tuples_strike3 = 0
    if not nr_transitions < myorder:
      # We are mostly interested in how many tuples are left after strike 3
      tuples_strike3 = collider.choose(nr_transitions, myorder ) - len(non_useable_combinations)