<commit_before># -*- coding: utf-8 -*-

from .boxcox import BoxCoxEndogTransformer

__all__ = ['LogEndogTransformer']


class LogEndogTransformer(BoxCoxEndogTransformer):
    """Apply a log transformation to an endogenous array

    When ``y`` is your endogenous array, the log transform is
    ``log(y + lmbda)``

    Parameters
    ----------

    lmbda : float, optional (default=0.)
        The value to add to ``y`` to make it non-negative. If, after adding
        ``lmbda``, there are still negative values, a ValueError will be
        raised.

    neg_action : str, optional (default="raise")
        How to respond if any values in ``y <= 0`` after adding ``lmbda``.
        One of ('raise', 'warn', 'ignore'). If anything other than 'raise',
        values <= 0 will be truncated to the value of ``floor``.

    floor : float, optional (default=1e-16)
        A positive value that truncate values to if there are values in ``y``
        that are zero or negative and ``neg_action`` is not 'raise'. Note that
        if values are truncated, invertibility will not be preserved, and the
        transformed array may not be perfectly inverse-transformed.
    """
    def __init__(self, lmbda=0, neg_action="raise", floor=1e-16):

        super().__init__(0, lmbda2=lmbda, neg_action=neg_action, floor=floor)

    def transform(self, y, exogenous=None, **transform_kwargs):
        """Apply the log transform to the array

        Parameters
        ----------<commit_msg>Add fit method to LogEndogTransformer for docs<commit_after># -*- coding: utf-8 -*-

from .boxcox import BoxCoxEndogTransformer

__all__ = ['LogEndogTransformer']


class LogEndogTransformer(BoxCoxEndogTransformer):
    """Apply a log transformation to an endogenous array

    When ``y`` is your endogenous array, the log transform is
    ``log(y + lmbda)``

    Parameters
    ----------

    lmbda : float, optional (default=0.)
        The value to add to ``y`` to make it non-negative. If, after adding
        ``lmbda``, there are still negative values, a ValueError will be
        raised.

    neg_action : str, optional (default="raise")
        How to respond if any values in ``y <= 0`` after adding ``lmbda``.
        One of ('raise', 'warn', 'ignore'). If anything other than 'raise',
        values <= 0 will be truncated to the value of ``floor``.

    floor : float, optional (default=1e-16)
        A positive value that truncate values to if there are values in ``y``
        that are zero or negative and ``neg_action`` is not 'raise'. Note that
        if values are truncated, invertibility will not be preserved, and the
        transformed array may not be perfectly inverse-transformed.
    """
    def __init__(self, lmbda=0, neg_action="raise", floor=1e-16):

        super().__init__(0, lmbda2=lmbda, neg_action=neg_action, floor=floor)

    def fit(self, y, exogenous=None):
        """Fit the transformer

        Must be called before ``transform``.

        Parameters
        ----------
        y : array-like or None, shape=(n_samples,)
            The endogenous (time-series) array.

        exogenous : array-like or None, shape=(n_samples, n_features), optional
            The exogenous array of additional covariates. Not used for
            endogenous transformers. Default is None, and non-None values will
            serve as pass-through arrays.
        """
        return super().fit(y, exogenous)

    def transform(self, y, exogenous=None, **transform_kwargs):
        """Apply the log transform to the array

        Parameters
        ----------
{'fraction_non_alphanumeric': 0.11350293542074363, 'fraction_numerical': 0.00726866088901314, 'mean_word_length': 2.6810699588477367, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3728596', 'n_tokens_mistral': 1031, 'n_tokens_neox': 964, 'n_words': 390}