# 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
            test_func, true_func, err_msg = func(self)

            def properties_to_test():
                for k in self.subset:
                    Lk = self.Lk_tensor[self.si_map[k]]
                    yield test_func(Lk, k)
            def properties_is_true():
                for k in self.subset:
                    yield true_func(self.laplacian, k)

            testing_list = [item for item in properties_to_test()]
            correct_list = [item for item in properties_is_true()]
            try:
                np.testing.assert_allclose(testing_list, correct_list, err_msg=err_msg)
            except TypeError:
                for idx, totest in enumerate(testing_list):
                    np.testing.assert_allclose(
                        totest, correct_list[idx],
                        err_msg=err_msg + ", fails at k == {}".format(idx)
                    )
        return wrapper

    @_test_array_close_deco
    def test_nonzero_counts(self):
        def test_func(Lk,k):
            return Lk.nonzero()[0].shape[0]
        def true_func(laplacian,k):
            nonzero_count = laplacian[k,:].nonzero()[0].shape[0]
            return 3*nonzero_count-2 if nonzero_count != 0 else 0
        err_msg = 'The nonzero count should be the same for Lk and laplacian[k,:]'

# 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

            test_func, true_func, err_msg = func(self)

            def properties_to_test():
                for k in self.subset:
                    Lk = self.Lk_tensor[self.si_map[k]]
                    yield test_func(Lk, k)
            def properties_is_true():
                for k in self.subset:
                    yield true_func(self.laplacian, k)

            testing_list = [item for item in properties_to_test()]
            correct_list = [item for item in properties_is_true()]
            try:
                np.testing.assert_allclose(testing_list, correct_list, err_msg=err_msg)
            except TypeError:
                for idx, totest in enumerate(testing_list):
                    np.testing.assert_allclose(
                        totest, correct_list[idx],
                        err_msg=err_msg + ", fails at k == {}".format(idx)
                    )
        return wrapper

    @_test_array_close_deco
    def test_nonzero_counts(self):
        def test_func(Lk,k):
            return Lk.nonzero()[0].shape[0]
        def true_func(laplacian,k):
            nonzero_count = laplacian[k,:].nonzero()[0].shape[0]
            return 3*nonzero_count-2 if nonzero_count != 0 else 0
        err_msg = 'The nonzero count should be the same for Lk and laplacian[k,:]'

        return test_func, true_func, err_msg