<commit_before>import numpy
import pyamgcl_ext
from pyamgcl_ext import coarsening, relaxation, solver_type
from scipy.sparse.linalg import LinearOperator

class make_solver:
    def __init__(self,
            A,
            coarsening=pyamgcl_ext.coarsening.smoothed_aggregation,
            relaxation=pyamgcl_ext.relaxation.spai0,
            solver=pyamgcl_ext.solver_type.bicgstabl,
            prm={}
            ):
        Acsr = A.tocsr()

        self.S = pyamgcl_ext.make_solver(
                coarsening, relaxation, solver, prm,
                Acsr.indptr.astype(numpy.int32),
                Acsr.indices.astype(numpy.int32),
                Acsr.data.astype(numpy.float64)
                )

    def __str__(self):
        return self.S.__str__()

    def __call__(self, rhs):
        return self.S(rhs.astype(numpy.float64))

class make_preconditioner(LinearOperator):
    def __init__(self,
            A,
            coarsening=pyamgcl_ext.coarsening.smoothed_aggregation,
            relaxation=pyamgcl_ext.relaxation.spai0,
            prm={}
            ):
        Acsr = A.tocsr()

        self.P = pyamgcl_ext.make_preconditioner(
                coarsening, relaxation, prm,
                Acsr.indptr.astype(numpy.int32),
                Acsr.indices.astype(numpy.int32),
                Acsr.data.astype(numpy.float64)
                )

        super(make_preconditioner, self).__init__(A.shape, self.P)

    def __str__(self):
        return self.P.__str__()

    def __call__(self, rhs):
        return self.P(rhs.astype(numpy.float64))
<commit_msg>Old style python inheritance<commit_after>import numpy
import pyamgcl_ext
from pyamgcl_ext import coarsening, relaxation, solver_type
from scipy.sparse.linalg import LinearOperator

class make_solver:
    def __init__(self,
            A,
            coarsening=pyamgcl_ext.coarsening.smoothed_aggregation,
            relaxation=pyamgcl_ext.relaxation.spai0,
            solver=pyamgcl_ext.solver_type.bicgstabl,
            prm={}
            ):
        Acsr = A.tocsr()

        self.S = pyamgcl_ext.make_solver(
                coarsening, relaxation, solver, prm,
                Acsr.indptr.astype(numpy.int32),
                Acsr.indices.astype(numpy.int32),
                Acsr.data.astype(numpy.float64)
                )

    def __str__(self):
        return self.S.__str__()

    def __call__(self, rhs):
        return self.S(rhs.astype(numpy.float64))

class make_preconditioner(LinearOperator):
    def __init__(self,
            A,
            coarsening=pyamgcl_ext.coarsening.smoothed_aggregation,
            relaxation=pyamgcl_ext.relaxation.spai0,
            prm={}
            ):
        Acsr = A.tocsr()

        self.P = pyamgcl_ext.make_preconditioner(
                coarsening, relaxation, prm,
                Acsr.indptr.astype(numpy.int32),
                Acsr.indices.astype(numpy.int32),
                Acsr.data.astype(numpy.float64)
                )

        LinearOperator.__init__(self, A.shape, self.P)

    def __str__(self):
        return self.P.__str__()

    def __call__(self, rhs):
        return self.P(rhs.astype(numpy.float64))

{'fraction_non_alphanumeric': 0.09484666455896301, 'fraction_numerical': 0.01138159974707556, 'mean_word_length': 1.99054820415879, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2179820', 'n_tokens_mistral': 1122, 'n_tokens_neox': 1061, 'n_words': 149}