# Path: dppy/exotic_dpps_core.py
# def uniform_permutation(N, random_state=None):
#     """ Draw a perputation :math:`\\sigma \\in \\mathfrak{S}_N` uniformly at random using Fisher-Yates' algorithm
# 
#     .. seealso::
# 
#         - `Fisher–Yates_shuffle <https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle>_
# 
#         - `Numpy shuffle <https://github.com/numpy/numpy/blob/d429f0fe16c0407509b1f20d997bf94f1027f61b/numpy/random/mtrand.pyx#L4027>_`
#     """
#     rng = check_random_state(random_state)
# 
#     sigma = np.arange(N)
#     for i in range(N - 1, 0, -1):  # reversed(range(1, N))
#         j = rng.randint(0, i + 1)
#         if j == i:
#             continue
#         sigma[j], sigma[i] = sigma[i], sigma[j]
# 
#     # for i in range(N - 1):
#     #     j = rng.randint(i, N)
#     #     sigma[j], sigma[i] = sigma[i], sigma[j]
# 
#     return sigma


import unittest
import numpy as np
import sys
from math import factorial
from collections import Counter
from scipy.stats import chisquare
from dppy.exotic_dpps_core import uniform_permutation
# coding: utf8
""" Unit tests:

- :class:`InclusionProbabilitiesProjectionDPP` to check that exact samplers for finite DPPs have the right (at least 1 and 2) inclusion probabilities
"""




sys.path.append('..')



class UniformityOfPermutation(unittest.TestCase):
    """ Test uniformity of the implementation of `uniform_permutation`
    """

    N = 5
    nb_perms = factorial(N)
    nb_samples = 5000

    @staticmethod
    def sample_to_label(samples):

        return ''.join(map(str, samples))

    def test_uniform_permutation_sampler(self):
        """
        """

# Path: dppy/exotic_dpps_core.py
# def uniform_permutation(N, random_state=None):
#     """ Draw a perputation :math:`\\sigma \\in \\mathfrak{S}_N` uniformly at random using Fisher-Yates' algorithm
# 
#     .. seealso::
# 
#         - `Fisher–Yates_shuffle <https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle>_
# 
#         - `Numpy shuffle <https://github.com/numpy/numpy/blob/d429f0fe16c0407509b1f20d997bf94f1027f61b/numpy/random/mtrand.pyx#L4027>_`
#     """
#     rng = check_random_state(random_state)
# 
#     sigma = np.arange(N)
#     for i in range(N - 1, 0, -1):  # reversed(range(1, N))
#         j = rng.randint(0, i + 1)
#         if j == i:
#             continue
#         sigma[j], sigma[i] = sigma[i], sigma[j]
# 
#     # for i in range(N - 1):
#     #     j = rng.randint(i, N)
#     #     sigma[j], sigma[i] = sigma[i], sigma[j]
# 
#     return sigma


# Path: tests/test_uniform_permutation.py
import unittest
import numpy as np
import sys
from math import factorial
from collections import Counter
from scipy.stats import chisquare
from dppy.exotic_dpps_core import uniform_permutation

# coding: utf8
""" Unit tests:

- :class:`InclusionProbabilitiesProjectionDPP` to check that exact samplers for finite DPPs have the right (at least 1 and 2) inclusion probabilities
"""




sys.path.append('..')



class UniformityOfPermutation(unittest.TestCase):
    """ Test uniformity of the implementation of `uniform_permutation`
    """

    N = 5
    nb_perms = factorial(N)
    nb_samples = 5000

    @staticmethod
    def sample_to_label(samples):

        return ''.join(map(str, samples))

    def test_uniform_permutation_sampler(self):
        """
        """

        samples = [uniform_permutation(self.N) for _ in range(self.nb_samples)]