<commit_before>#!/usr/bin/env python
# encoding: utf-8
#
# spectrum.py
#
# Licensed under a 3-clause BSD license.

# Revision history:
#     13 Apr 2016 <NAME>
#       Initial version


from __future__ import division
from __future__ import print_function
from __future__ import absolute_import

import numpy as np
import matplotlib.pyplot as plt

from astropy.units import Quantity, dimensionless_unscaled


class Spectrum(Quantity):
    """A class representing an spectrum with extra functionality.

    Parameters:
        flux (array-like):
            The 1-D array contianing the spectrum.
        unit (astropy.unit.Unit, optional):
            The unit of the flux spectrum.
        scale (float, optional):
            The scale factor of the spectrum flux.
        ivar (array-like, optional):
            The inverse variance array for ``spectrum``. Must have the same
            number of elements.
        mask (array-like, optional):
            The mask array for ``spectrum``. Must have the same number of
            elements.
        wavelength (array-like, optional):
            The wavelength solution for ``spectrum``. Must have the same number
            of elements.
        wavelength_unit (astropy.unit.Unit, optional):
            The units of the wavelength solution.

    Returns:
        spectrum:
            An astropy Quantity-like object that contains the spectrum, as well
            as inverse variance, mask, and wavelengh (itself a Quantity array).

    """

    def __new__(cls, flux, scale=1, unit=dimensionless_unscaled,
                wavelength_unit=dimensionless_unscaled, ivar=None, mask=None,
                wavelength=None, dtype=None, copy=True):

        flux = np.array(flux) * scale

        obj = Quantity(flux, unit=unit, dtype=dtype, copy=copy)
        obj = obj.view(cls)
        obj._set_unit(unit)

        obj.ivar = (np.array(ivar) / (scale ** 2)) if ivar is not None else None
        obj.mask = np.array(mask) if mask is not None else None

        if wavelength is None:<commit_msg>makes Spectrum accept **kwargs arguments<commit_after>#!/usr/bin/env python
# encoding: utf-8
#
# spectrum.py
#
# Licensed under a 3-clause BSD license.

# Revision history:
#     13 Apr 2016 <NAME>
#       Initial version


from __future__ import division
from __future__ import print_function
from __future__ import absolute_import

import numpy as np
import matplotlib.pyplot as plt

from astropy.units import Quantity, dimensionless_unscaled


class Spectrum(Quantity):
    """A class representing an spectrum with extra functionality.

    Parameters:
        flux (array-like):
            The 1-D array contianing the spectrum.
        unit (astropy.unit.Unit, optional):
            The unit of the flux spectrum.
        scale (float, optional):
            The scale factor of the spectrum flux.
        ivar (array-like, optional):
            The inverse variance array for ``spectrum``. Must have the same
            number of elements.
        mask (array-like, optional):
            The mask array for ``spectrum``. Must have the same number of
            elements.
        wavelength (array-like, optional):
            The wavelength solution for ``spectrum``. Must have the same number
            of elements.
        wavelength_unit (astropy.unit.Unit, optional):
            The units of the wavelength solution.

    Returns:
        spectrum:
            An astropy Quantity-like object that contains the spectrum, as well
            as inverse variance, mask, and wavelengh (itself a Quantity array).

    """

    def __new__(cls, flux, scale=1, unit=dimensionless_unscaled,
                wavelength_unit=dimensionless_unscaled, ivar=None, mask=None,
                wavelength=None, dtype=None, copy=True, **kwargs):

        flux = np.array(flux) * scale

        obj = Quantity(flux, unit=unit, dtype=dtype, copy=copy)
        obj = obj.view(cls)
        obj._set_unit(unit)

        obj.ivar = (np.array(ivar) / (scale ** 2)) if ivar is not None else None
        obj.mask = np.array(mask) if mask is not None else None

        if wavelength is None:
{'fraction_non_alphanumeric': 0.08053204353083435, 'fraction_numerical': 0.00532043530834341, 'mean_word_length': 2.423841059602649, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4915527', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1098, 'n_words': 414}