def test_k_resolutions_list_simple():
    ans_ground = [[0, 0, 4], [0, 1, 3], [0, 2, 2], [0, 3, 1], 
                  [0, 4, 0], [1, 0, 3], [1, 1, 2], [1, 2, 1], 
                  [1, 3, 0], [2, 0, 2], [2, 1, 1], [2, 2, 0],  
                  [3, 0, 1], [3, 1, 0], [4, 0, 0]]
    ans = k_resolutions_list(4, 3)

    assert_equal(len(ans), len(ans_ground))
    for i in range(len(ans)):
        assert_true(ans[i] in ans_ground)
def test_k_resolutions_list_extreme():
    with assert_raises(IOError):
        k_resolutions_list(5, 0)
def test_k_resolutions_list_extreme_1():
    ans_ground = [[1]]
    ans = k_resolutions_list(1, 1)
    assert_array_equal(ans, ans_ground)
예제 #4
0

if __name__ == "__main__":
    """
    Comparisons between closed form and length of lists of k-resolutions with no, lower or upper constraints.
    """

    #######################
    # k -resolutions of n #
    #######################

    n = 7
    k = 5

    closed_form = number_of_k_resolutions_n(n, k)
    counting_solutions = len(k_resolutions_list(n, k))

    print '\n' + str(k) + '-resolutions of ' + str(n) + ', unconstrained:'
    print 'closed form            = ' + str(closed_form)
    print 'counting the solutions = ' + str(counting_solutions)
    print 'It is ' + str(closed_form == counting_solutions) + ' that the closed form equals the direct enumerations. \n'

    #########################################
    # k -resolutions of n lower constraints #
    #########################################

    n_lower = 15
    t_lower = [3, 4, 1, 2]
    k_lower = len(t_lower)

    closed_form = number_of_k_resolutions_lower_constraints(n_lower, t_lower)