Exemple #1
0
def test_n_permutations_edges():
    with pytest.raises(ValueError):
        n_permutations(-1, 1)
    with pytest.raises(ValueError):
        n_permutations(1, -1)
    assert n_permutations(0, 0) == 0
    assert n_permutations(2, 3) == 0
    assert n_permutations(5) == n_permutations(5, 5)
Exemple #2
0
    def permutations(self, r: Optional[int] = None):
        """See itertools.permutations_

        .. _itertools.permutations: https://docs.python.org/3/library/itertools.html#itertools.permutations
        """  # noqa
        this_len = len_or_none(self)
        if this_len is None:
            length = None
        else:
            length = n_permutations(this_len, r)

        return FIt(permutations(self, r), length)
Exemple #3
0
def test_n_permutations():
    assert n_permutations(3, 2) == 6