# Path: sparsereg/model/base.py
# class PrintMixin:
#     def print_model(self, input_features=None, precision=3):
#         input_features = input_features or ["x_{}".format(i) for i in range(len(self.coef_))]
#         return print_model(self.coef_, input_features, intercept=self.intercept_, precision=precision)


import warnings
import numpy as np
from sklearn.base import RegressorMixin
from sklearn.exceptions import ConvergenceWarning
from sklearn.linear_model.base import LinearModel
from sklearn.utils.validation import check_X_y
from sparsereg.model.base import PrintMixin


eps = np.finfo(np.float64).eps


def scale_sigma(est, X_offset, X_scale):
    if est.fit_intercept:
        std_intercept = np.sqrt(np.abs(X_offset @ np.diag(est.sigma_).T))
    else:
        std_intercept = 0
    sigma = np.diag(est.sigma_) / (X_scale + eps)
    with warnings.catch_warnings():
        warnings.filterwarnings("ignore")
        std_coef = np.sqrt(sigma)
    return std_intercept, std_coef


class JMAP(LinearModel, RegressorMixin, PrintMixin):
    def __init__(
        self,
        ae0=1e-6,
        be0=1e-6,
        af0=1e-6,
        bf0=1e-6,
        max_iter=300,
        tol=1e-3,
        normalize=False,
        fit_intercept=True,
        copy_X=True,
    ):

# Path: sparsereg/model/base.py
# class PrintMixin:
#     def print_model(self, input_features=None, precision=3):
#         input_features = input_features or ["x_{}".format(i) for i in range(len(self.coef_))]
#         return print_model(self.coef_, input_features, intercept=self.intercept_, precision=precision)


# Path: sparsereg/model/bayes.py
import warnings
import numpy as np
from sklearn.base import RegressorMixin
from sklearn.exceptions import ConvergenceWarning
from sklearn.linear_model.base import LinearModel
from sklearn.utils.validation import check_X_y
from sparsereg.model.base import PrintMixin



eps = np.finfo(np.float64).eps


def scale_sigma(est, X_offset, X_scale):
    if est.fit_intercept:
        std_intercept = np.sqrt(np.abs(X_offset @ np.diag(est.sigma_).T))
    else:
        std_intercept = 0
    sigma = np.diag(est.sigma_) / (X_scale + eps)
    with warnings.catch_warnings():
        warnings.filterwarnings("ignore")
        std_coef = np.sqrt(sigma)
    return std_intercept, std_coef


class JMAP(LinearModel, RegressorMixin, PrintMixin):
    def __init__(
        self,
        ae0=1e-6,
        be0=1e-6,
        af0=1e-6,
        bf0=1e-6,
        max_iter=300,
        tol=1e-3,
        normalize=False,
        fit_intercept=True,
        copy_X=True,
    ):

        self.max_iter = max_iter