<commit_before>"""Finding coefficients via regression."""
from .parameter import Parameter
from .basis import Basis
from .poly import Poly
from .projectedpoly import Projectedpoly
import numpy as np
from .stats import Statistics, getAllSobol
import scipy
from .qr import solveCLSQ
from .utils import cell2matrix
from scipy.stats import linregress

class Polyreg(Poly):
    """
    The class defines a Polyreg object. It is the child of Poly.
    :param Parameter parameters:
        A list of parameters.
    :param Basis basis:
        A basis selected for the multivariate polynomial.
    :param matrix training_inputs:
        A N-by-d matrix of input training points.
    :param matrix training_outputs:
        A N-by-1 matrix of output training points.
    :param matrix training_grads:
        A N-by-d matrix of gradient evaluations.
    :param callable fun:
        Instead of specifying the output training points, the user can also provide a callable function, which will be evaluated.
    """
    def __init__(self, parameters, basis, training_inputs = None, fun=None, training_outputs=None, training_grads=None, quadrature_rule = None, no_of_quad_points = None, gradmethod=None):
        super(Polyreg, self).__init__(parameters, basis)
        if not(training_inputs is None):
            self.x = training_inputs
            if len(self.x.shape) == 1:
                self.x = np.reshape(self.x,(len(self.x),1))
            assert self.x.shape[1] == len(self.parameters) # Check that x is in the correct shape

        if not((training_outputs is None) ^ (fun is None)):
            raise ValueError("Specify atleast one of fun or training_outputs.")
        if not(fun is None):
            try:
                self.y = np.apply_along_axis(fun, 1, self.x)
            except:
                raise ValueError("Fun must be callable.")
        else:
            self.y = training_outputs
        if self.dimensions != self.basis.elements.shape[1]:
            raise(ValueError, 'Polyreg:__init__:: The number of parameters and the number of dimensions in the index set must be the same.')
        self.training_grads = training_grads
        self.gradmethod = gradmethod<commit_msg>minor fix<commit_after>"""Finding coefficients via regression."""
from .parameter import Parameter
from .basis import Basis
from .poly import Poly
from .projectedpoly import Projectedpoly
import numpy as np
from .stats import Statistics, getAllSobol
import scipy
from .qr import solveCLSQ
from .utils import cell2matrix
from scipy.stats import linregress

class Polyreg(Poly):
    """
    The class defines a Polyreg object. It is the child of Poly.
    :param Parameter parameters:
        A list of parameters.
    :param Basis basis:
        A basis selected for the multivariate polynomial.
    :param matrix training_inputs:
        A N-by-d matrix of input training points.
    :param matrix training_outputs:
        A N-by-1 matrix of output training points.
    :param matrix training_grads:
        A N-by-d matrix of gradient evaluations.
    :param callable fun:
        Instead of specifying the output training points, the user can also provide a callable function, which will be evaluated.
    """
    def __init__(self, parameters, basis, training_inputs = None, fun=None, training_outputs=None, training_grads=None, quadrature_rule = None, no_of_quad_points = None, gradmethod=None):
        super(Polyreg, self).__init__(parameters, basis)
        if not(training_inputs is None):
            self.x = training_inputs
            if len(self.x.shape) == 1:
                self.x = np.reshape(self.x,(len(self.x),1))
            assert self.x.shape[1] == len(self.parameters) # Check that x is in the correct shape

        if not((training_outputs is None) ^ (fun is None)):
            raise ValueError("Specify atleast one of fun or training_outputs.")
        if not(fun is None):
            try:
                self.y = np.apply_along_axis(fun, 1, self.x)
            except:
                raise ValueError("Fun must be callable.")
        else:
            self.y = training_outputs
        if self.dimensions != self.basis.elements.shape[1]:
            raise ValueError('Polyreg:__init__:: The number of parameters and the number of dimensions in the index set must be the same.')
        self.training_grads = training_grads
        self.gradmethod = gradmethod
{'fraction_non_alphanumeric': 0.0786056049213944, 'fraction_numerical': 0.003189792663476874, 'mean_word_length': 2.7585616438356166, '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': '4191156', 'n_tokens_mistral': 1208, 'n_tokens_neox': 1173, 'n_words': 446}