# Path: pyamg/aggregation/aggregation.py
# def smoothed_aggregation_solver(A, B=None, BH=None,
#                                 symmetry='hermitian', strength='symmetric',
#                                 aggregate='standard',
#                                 smooth=('jacobi', {'omega': 4.0/3.0}),
#                                 presmoother=('block_gauss_seidel',
#                                              {'sweep': 'symmetric'}),
#                                 postsmoother=('block_gauss_seidel',
#                                               {'sweep': 'symmetric'}),
#                                 improve_candidates=(('block_gauss_seidel',
#                                                      {'sweep': 'symmetric',
#                                                       'iterations': 4}),
#                                                     None),
#                                 max_levels=10, max_coarse=10,
#                                 diagonal_dominance=False,
#                                 keep=False, **kwargs):
# def _extend_hierarchy(levels, strength, aggregate, smooth, improve_candidates,
#                       diagonal_dominance=False, keep=True):
#     def unpack_arg(v):
#             A = csr_matrix(A)
#     A = A.asfptype()
#         B = np.kron(np.ones((int(A.shape[0]/get_blocksize(A)), 1), dtype=A.dtype),
#                     np.eye(get_blocksize(A), dtype=A.dtype))
#         B = np.asarray(B, dtype=A.dtype)
#             B = B.reshape(-1, 1)
#             BH = B.copy()
#             BH = np.asarray(BH, dtype=A.dtype)
#                 BH = BH.reshape(-1, 1)
#     A = levels[-1].A
#     B = levels[-1].B
#         AH = A.H.asformat(A.format)
#         BH = levels[-1].BH
#         C = symmetric_strength_of_connection(A, **kwargs)
#         C = classical_strength_of_connection(A, **kwargs)
#         C = distance_strength_of_connection(A, **kwargs)
#             C = evolution_strength_of_connection(A, **kwargs)
#             C = evolution_strength_of_connection(A, B, **kwargs)
#         C = energy_based_strength_of_connection(A, **kwargs)
#         C = kwargs['C'].tocsr()
#         C = algebraic_distance(A, **kwargs)
#         C = affinity_distance(A, **kwargs)
#         C = A.tocsr()
#         C = eliminate_diag_dom_nodes(A, C, **kwargs)
#         B = relaxation_as_linear_operator((fn, kwargs), A, b) * B
#             BH = relaxation_as_linear_operator((fn, kwargs), AH, b) * BH
#     T, B = fit_candidates(AggOp, B)
#         TH, BH = fit_candidates(AggOp, BH)
#         P = jacobi_prolongation_smoother(A, T, C, B, **kwargs)
#         P = richardson_prolongation_smoother(A, T, **kwargs)
#         P = energy_prolongation_smoother(A, T, C, B, None, (False, {}),
#                                          **kwargs)
#         P = T
#         R = P.H
#         R = P.T
#             R = jacobi_prolongation_smoother(AH, TH, C, BH, **kwargs).H
#             R = richardson_prolongation_smoother(AH, TH, **kwargs).H
#             R = energy_prolongation_smoother(AH, TH, C, BH, None, (False, {}),
#                                              **kwargs)
#             R = R.H
#             R = T.H
#     A = R * A * P              # Galerkin operator


import numpy as np
from scipy.sparse import csr_matrix
from pyamg.aggregation.aggregation import fit_candidates
from numpy.testing import TestCase, assert_almost_equal
        self.cases.append((
            csr_matrix((np.ones(4), np.array([0, 0, 1, 1]), np.arange(5)),
                       shape=(4, 2)), (1 + 3j) * np.arange(4).reshape(4, 1)))
        # two aggregates two candidates
        self.cases.append((
            csr_matrix((np.ones(4), np.array([0, 0, 1, 1]), np.arange(5)),
                       shape=(4, 2)),
            (1 + 0j) * np.vstack((np.ones(4), np.arange(4))).T))
        self.cases.append((
            csr_matrix((np.ones(4), np.array([0, 0, 1, 1]), np.arange(5)),
                       shape=(4, 2)),
            (0 + 3j) * np.vstack((np.ones(4), np.arange(4))).T))
        self.cases.append((
            csr_matrix((np.ones(4), np.array([0, 0, 1, 1]), np.arange(5)),
                       shape=(4, 2)),
            (1 + 3j) * np.vstack((np.ones(4), np.arange(4))).T))
        self.cases.append((
            csr_matrix((np.ones(4), np.array([0, 0, 1, 1]), np.arange(5)),
                       shape=(4, 2)),
            np.array([[-1 + 4j, 1 + 3j], [0 + 5j, 6 + 0j],
                      [5 - 2j, 7 + 1j], [9 - 8j, 7 + 2j]])))

    def test_all_cases(self):
        def mask_candidate(AggOp, candidates):
            # mask out all dofs that are not included in the aggregation
            candidates[np.where(np.diff(AggOp.indptr) == 0)[0], :] = 0

        for AggOp, fine_candidates in self.cases:
            mask_candidate(AggOp, fine_candidates)


# Path: pyamg/aggregation/aggregation.py
# def smoothed_aggregation_solver(A, B=None, BH=None,
#                                 symmetry='hermitian', strength='symmetric',
#                                 aggregate='standard',
#                                 smooth=('jacobi', {'omega': 4.0/3.0}),
#                                 presmoother=('block_gauss_seidel',
#                                              {'sweep': 'symmetric'}),
#                                 postsmoother=('block_gauss_seidel',
#                                               {'sweep': 'symmetric'}),
#                                 improve_candidates=(('block_gauss_seidel',
#                                                      {'sweep': 'symmetric',
#                                                       'iterations': 4}),
#                                                     None),
#                                 max_levels=10, max_coarse=10,
#                                 diagonal_dominance=False,
#                                 keep=False, **kwargs):
# def _extend_hierarchy(levels, strength, aggregate, smooth, improve_candidates,
#                       diagonal_dominance=False, keep=True):
#     def unpack_arg(v):
#             A = csr_matrix(A)
#     A = A.asfptype()
#         B = np.kron(np.ones((int(A.shape[0]/get_blocksize(A)), 1), dtype=A.dtype),
#                     np.eye(get_blocksize(A), dtype=A.dtype))
#         B = np.asarray(B, dtype=A.dtype)
#             B = B.reshape(-1, 1)
#             BH = B.copy()
#             BH = np.asarray(BH, dtype=A.dtype)
#                 BH = BH.reshape(-1, 1)
#     A = levels[-1].A
#     B = levels[-1].B
#         AH = A.H.asformat(A.format)
#         BH = levels[-1].BH
#         C = symmetric_strength_of_connection(A, **kwargs)
#         C = classical_strength_of_connection(A, **kwargs)
#         C = distance_strength_of_connection(A, **kwargs)
#             C = evolution_strength_of_connection(A, **kwargs)
#             C = evolution_strength_of_connection(A, B, **kwargs)
#         C = energy_based_strength_of_connection(A, **kwargs)
#         C = kwargs['C'].tocsr()
#         C = algebraic_distance(A, **kwargs)
#         C = affinity_distance(A, **kwargs)
#         C = A.tocsr()
#         C = eliminate_diag_dom_nodes(A, C, **kwargs)
#         B = relaxation_as_linear_operator((fn, kwargs), A, b) * B
#             BH = relaxation_as_linear_operator((fn, kwargs), AH, b) * BH
#     T, B = fit_candidates(AggOp, B)
#         TH, BH = fit_candidates(AggOp, BH)
#         P = jacobi_prolongation_smoother(A, T, C, B, **kwargs)
#         P = richardson_prolongation_smoother(A, T, **kwargs)
#         P = energy_prolongation_smoother(A, T, C, B, None, (False, {}),
#                                          **kwargs)
#         P = T
#         R = P.H
#         R = P.T
#             R = jacobi_prolongation_smoother(AH, TH, C, BH, **kwargs).H
#             R = richardson_prolongation_smoother(AH, TH, **kwargs).H
#             R = energy_prolongation_smoother(AH, TH, C, BH, None, (False, {}),
#                                              **kwargs)
#             R = R.H
#             R = T.H
#     A = R * A * P              # Galerkin operator


# Path: pyamg/aggregation/tests/test_tentative.py
import numpy as np
from scipy.sparse import csr_matrix
from pyamg.aggregation.aggregation import fit_candidates
from numpy.testing import TestCase, assert_almost_equal

        self.cases.append((
            csr_matrix((np.ones(4), np.array([0, 0, 1, 1]), np.arange(5)),
                       shape=(4, 2)), (1 + 3j) * np.arange(4).reshape(4, 1)))
        # two aggregates two candidates
        self.cases.append((
            csr_matrix((np.ones(4), np.array([0, 0, 1, 1]), np.arange(5)),
                       shape=(4, 2)),
            (1 + 0j) * np.vstack((np.ones(4), np.arange(4))).T))
        self.cases.append((
            csr_matrix((np.ones(4), np.array([0, 0, 1, 1]), np.arange(5)),
                       shape=(4, 2)),
            (0 + 3j) * np.vstack((np.ones(4), np.arange(4))).T))
        self.cases.append((
            csr_matrix((np.ones(4), np.array([0, 0, 1, 1]), np.arange(5)),
                       shape=(4, 2)),
            (1 + 3j) * np.vstack((np.ones(4), np.arange(4))).T))
        self.cases.append((
            csr_matrix((np.ones(4), np.array([0, 0, 1, 1]), np.arange(5)),
                       shape=(4, 2)),
            np.array([[-1 + 4j, 1 + 3j], [0 + 5j, 6 + 0j],
                      [5 - 2j, 7 + 1j], [9 - 8j, 7 + 2j]])))

    def test_all_cases(self):
        def mask_candidate(AggOp, candidates):
            # mask out all dofs that are not included in the aggregation
            candidates[np.where(np.diff(AggOp.indptr) == 0)[0], :] = 0

        for AggOp, fine_candidates in self.cases:
            mask_candidate(AggOp, fine_candidates)


            Q, coarse_candidates = fit_candidates(AggOp, fine_candidates)