# 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
from functools import wraps
import numpy as np
import numpy.testing
import scipy as sp
        assert np.all(if_symmetric), 'One or more Lk is not symmetric'

    def _test_other_zeros(self):
        pass
        # You do not need this since if nonzero terms is 3n-2 and Lk row Lk col Lk diag are close.
        # Then this is automatically become true.

    def test_neighbors(self):
        true_neighbors = [self.laplacian[k,:].nonzero()[1] for k in self.subset]
        for idx, nb in enumerate(self.nbk):
            np.testing.assert_array_equal(
                nb, true_neighbors[idx],
                err_msg='calculated nbk should be the same as the non zero term in laplacian'
            )

    def test_si_map_index(self):
        keys, values = zip(*self.si_map.items())
        sorted_key = np.sort(keys)
        sorted_subset = np.sort(self.subset)
        np.testing.assert_array_equal(
            sorted_key, sorted_subset,
            err_msg='The index in subset should be identical to that in si_map'
        )

    def test_Lk_nbk_size_match(self):
        if_size_match = [Lk.shape[0] == self.nbk[k].shape[0] for k,Lk in enumerate(self.Lk_tensor)]
        assert np.all(if_size_match), 'One or more size of Lk and nbk does not match'

class TestLkWithWholeSubset(BaseTestLkNeighbors):
    def generate_laplacian(self):

# 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_Y.py
from megaman.relaxation.precomputed import *
from .utils import generate_toy_laplacian
from functools import wraps
import numpy as np
import numpy.testing
import scipy as sp

        assert np.all(if_symmetric), 'One or more Lk is not symmetric'

    def _test_other_zeros(self):
        pass
        # You do not need this since if nonzero terms is 3n-2 and Lk row Lk col Lk diag are close.
        # Then this is automatically become true.

    def test_neighbors(self):
        true_neighbors = [self.laplacian[k,:].nonzero()[1] for k in self.subset]
        for idx, nb in enumerate(self.nbk):
            np.testing.assert_array_equal(
                nb, true_neighbors[idx],
                err_msg='calculated nbk should be the same as the non zero term in laplacian'
            )

    def test_si_map_index(self):
        keys, values = zip(*self.si_map.items())
        sorted_key = np.sort(keys)
        sorted_subset = np.sort(self.subset)
        np.testing.assert_array_equal(
            sorted_key, sorted_subset,
            err_msg='The index in subset should be identical to that in si_map'
        )

    def test_Lk_nbk_size_match(self):
        if_size_match = [Lk.shape[0] == self.nbk[k].shape[0] for k,Lk in enumerate(self.Lk_tensor)]
        assert np.all(if_size_match), 'One or more size of Lk and nbk does not match'

class TestLkWithWholeSubset(BaseTestLkNeighbors):
    def generate_laplacian(self):

        return generate_toy_laplacian()