Exemplo n.º 1
0
def test_permutations_versus_reference_implementation(two_ints):
    num = two_ints[0]
    choose = two_ints[1]

    result = stats.permutations(num, choose=choose)
    reference = stats._permutations_reference(num, choose=choose)
    assert result == reference
Exemplo n.º 2
0
def test_permutations_there_and_back(two_ints):
    num = two_ints[0]
    choose = two_ints[1]

    result = stats.permutations(num, choose=choose)
    top_to_bottom = [result]
    top_to_bottom.extend(range(num, num - choose, -1))
    and_back = reduce(operator.truediv, top_to_bottom)

    assert round(and_back) == 1
Exemplo n.º 3
0
def test_permutations_factorial(integer):
    result = stats.permutations(integer)
    assert result == factorial(integer)
Exemplo n.º 4
0
def test_permutations_slow_number_equal_choose(integer):
    result = stats.permutations(integer)
    result_choose = stats.permutations(integer, choose=integer)
    assert result == result_choose