예제 #1
0
파일: test_utils.py 프로젝트: clbarnes/f_it
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)
예제 #2
0
파일: fit.py 프로젝트: wroldwiedbwe/f_it
    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)
예제 #3
0
파일: test_utils.py 프로젝트: clbarnes/f_it
def test_n_permutations():
    assert n_permutations(3, 2) == 6