# Path: megaman/relaxation/tests/utils.py
# def generate_toy_laplacian(n=1000):
#     neighbor_counts = 10
#     adjacency_mat = np.zeros((n,n))
#     for i in range(n):
#         x = np.ones(neighbor_counts,dtype=np.int32)*i
#         y = np.random.choice(n, neighbor_counts, replace=False)
#         adjacency_mat[(x,y)] = 1
# 
#     np.fill_diagonal(adjacency_mat,0)
#     adjacency_mat = (adjacency_mat.T + adjacency_mat) / 2
#     degree = np.sum(adjacency_mat,axis=1)
#     degree_mat = np.diag(degree)
# 
#     return sp.sparse.csc_matrix(degree_mat - adjacency_mat)


from megaman.relaxation.precomputed import *
from .utils import generate_toy_laplacian

    def generate_toy_Y(self):
        return np.random.uniform(size=self.n)

    def ij_is_neighbors(self,i,j):
        return self.laplacian[i,j] != 0

    def project_S_from_laplacian(self):
        # TODO: make the test process faster!
        S = [ self.Y[i]-self.Y[j] for i in np.arange(self.n) \
              for j in np.arange(i+1,self.n) \
              if self.ij_is_neighbors(i,j) ]
        pairs = [ [i,j] for i in np.arange(self.n) \
                  for j in np.arange(i+1,self.n) \
                  if self.ij_is_neighbors(i,j) ]
        return np.array(S), np.array(pairs)

    def test_A_length_equality(self):
        A_length = self.A.shape[0]
        correct_A_length = self.correct_S.shape[0]
        assert A_length == correct_A_length, 'The first dimension of A is calculated wrong.'

    def test_pairs(self):
        np.testing.assert_array_equal(
            self.pairs, self.correct_pairs,
            err_msg='Sorted pairs should be the same.'
        )

    def test_A(self):
        testing_S = self.A.dot(self.Y)

# Path: megaman/relaxation/tests/utils.py
# def generate_toy_laplacian(n=1000):
#     neighbor_counts = 10
#     adjacency_mat = np.zeros((n,n))
#     for i in range(n):
#         x = np.ones(neighbor_counts,dtype=np.int32)*i
#         y = np.random.choice(n, neighbor_counts, replace=False)
#         adjacency_mat[(x,y)] = 1
# 
#     np.fill_diagonal(adjacency_mat,0)
#     adjacency_mat = (adjacency_mat.T + adjacency_mat) / 2
#     degree = np.sum(adjacency_mat,axis=1)
#     degree_mat = np.diag(degree)
# 
#     return sp.sparse.csc_matrix(degree_mat - adjacency_mat)


# Path: megaman/relaxation/tests/test_precomputed_S.py
from megaman.relaxation.precomputed import *
from .utils import generate_toy_laplacian


    def generate_toy_Y(self):
        return np.random.uniform(size=self.n)

    def ij_is_neighbors(self,i,j):
        return self.laplacian[i,j] != 0

    def project_S_from_laplacian(self):
        # TODO: make the test process faster!
        S = [ self.Y[i]-self.Y[j] for i in np.arange(self.n) \
              for j in np.arange(i+1,self.n) \
              if self.ij_is_neighbors(i,j) ]
        pairs = [ [i,j] for i in np.arange(self.n) \
                  for j in np.arange(i+1,self.n) \
                  if self.ij_is_neighbors(i,j) ]
        return np.array(S), np.array(pairs)

    def test_A_length_equality(self):
        A_length = self.A.shape[0]
        correct_A_length = self.correct_S.shape[0]
        assert A_length == correct_A_length, 'The first dimension of A is calculated wrong.'

    def test_pairs(self):
        np.testing.assert_array_equal(
            self.pairs, self.correct_pairs,
            err_msg='Sorted pairs should be the same.'
        )

    def test_A(self):
        testing_S = self.A.dot(self.Y)

        np.testing.assert_allclose(