<commit_before># Third-party
import numpy as np
from scipy.special import wofz

__all__ = ['voigt']

def voigt(x, amp, x0, G_std, L_fwhm):
    """
    Voigt profile - convolution of a Gaussian and Lorentzian.

    When G_std -> 0, the profile approaches a Lorentzian. When L_fwhm=0,
    the profile is a Gaussian.

    Parameters
    ----------
    x : numeric, array_like
    amp : numeric
        Amplitude of the profile (integral).
    x0 : numeric
        Centroid.
    G_std : numeric
        Standard of deviation of the Gaussian component.
    L_fwhm : numeric
        FWHM of the Lorentzian component.
    """

    _x = x-x0
    z = (_x + 1j*L_fwhm/2.) / (np.sqrt(2.)*G_std)

    return amp * wofz(z).real / (np.sqrt(2.*np.pi)*G_std)<commit_msg>add voigt polynomial models<commit_after># Third-party
import numpy as np
from numpy.polynomial.polynomial import polyval
from scipy.special import wofz

__all__ = ['voigt', 'voigt_constant', 'voigt_polynomial']

def voigt(x, amp, x0, G_std, L_fwhm):
    """
    Voigt profile - convolution of a Gaussian and Lorentzian.

    When G_std -> 0, the profile approaches a Lorentzian. When L_fwhm=0,
    the profile is a Gaussian.

    Parameters
    ----------
    x : numeric, array_like
    amp : numeric
        Amplitude of the profile (integral).
    x0 : numeric
        Centroid.
    G_std : numeric
        Standard of deviation of the Gaussian component.
    L_fwhm : numeric
        FWHM of the Lorentzian component.
    """

    _x = x-x0
    z = (_x + 1j*L_fwhm/2.) / (np.sqrt(2.)*G_std)

    return amp * wofz(z).real / (np.sqrt(2.*np.pi)*G_std)

def voigt_constant(x, amp, x_0, std_G, fwhm_L, C):
    """
    Voigt profile plus a constant background.

    Parameters
    ----------
    x : numeric, array_like
    amp : numeric
        Amplitude of the profile (integral).
    x0 : numeric
        Centroid.
    G_std : numeric
        Standard of deviation of the Gaussian component.
    L_fwhm : numeric
        FWHM of the Lorentzian component.
    C : numeric
        Background
    """
    return voigt(x, amp, x_0, std_G, fwhm_L) + C

def voigt_polynomial(x, amp, x_0, std_G, fwhm_L, bg_coef):
    """
    Voigt profile plus a constant background.

    Parameters
    ----------
    x : numeric, array_like
    amp : numeric
        Amplitude of the profile (integral).
    x0 : numeric
        Centroid.
    G_std : numeric
        Standard of deviation of the Gaussian component.
    L_fwhm : numeric
        FWHM of the Lorentzian component.
    bg_coef : iterable
        List of polynomial coefficients.
    """
    return voigt(x, amp, x_0, std_G, fwhm_L) + polyval(x-x_0, np.atleast_1d(bg_coef))
{'fraction_non_alphanumeric': 0.10404191616766467, 'fraction_numerical': 0.009730538922155689, 'mean_word_length': 2.3040791100123608, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4202904', 'n_tokens_mistral': 977, 'n_tokens_neox': 897, 'n_words': 280}