<commit_before>#!/usr/bin/python

from __future__ import division, print_function

import copy
import logging

import numpy as np
import matplotlib.pyplot as plt
from PyAstronomy import pyasl
from scipy.interpolate import InterpolatedUnivariateSpline, interp1d

import spectrum_overload.norm as norm

"""Spectrum Class."""

# Begun August 2016
# <NAME>


class Spectrum(object):
    """Spectrum class to represent and manipulate astronomical spectra.

    Attributes
    ----------
    xaxis:np.ndarray
        The wavelength or pixel position values.
    flux: np.ndarray, array-like, list
        The extracted flux (measured intensity of light).
    calibrated: bool
        Flag to indicate calibration state. (Default = True.)
    header: astropy.Header, dict-like
        Header information of observation.

    """
    def __init__(self, flux=None, xaxis=None, calibrated=True, header=None, interp_method="spline"):
        """Initalise a Spectrum object."""

        # Some checks before creating class
        if isinstance(flux, str):
            raise TypeError("Cannot assign {} to the flux attribute".format(
                type(flux)))
        elif isinstance(xaxis, str):
            raise TypeError("Cannot assign {} to the xaxis attribute".format(
                type(xaxis)))

        if flux is not None:
            self._flux = np.asarray(flux)
        else:
            self._flux = flux

        if xaxis is None:
            if flux is None:
                self._xaxis = None
            else:
                # Applying range to xaxis of equal length of flux
                try:
                    self._xaxis = np.arange(len(flux))
                except TypeError:
                    print("TypeError caught because flux has no length")
                    self._xaxis = None
        else:
            self._xaxis = np.asarray(xaxis)  # Setter not used - need asarray

        # Check assigned lengths
        self.length_check()
        self.calibrated = calibrated
        if header is None:
            self.header = {}
        else:
            self.header = header   # Access header with a dictionary call.

    @property
    def interp_method(self):
        """Getter for the interp_method attribute."""
        return self._interp_method
<commit_msg>Add interp_method to __init__<commit_after>#!/usr/bin/python

from __future__ import division, print_function

import copy
import logging

import numpy as np
import matplotlib.pyplot as plt
from PyAstronomy import pyasl
from scipy.interpolate import InterpolatedUnivariateSpline, interp1d

import spectrum_overload.norm as norm

"""Spectrum Class."""

# Begun August 2016
# <NAME>


class Spectrum(object):
    """Spectrum class to represent and manipulate astronomical spectra.

    Attributes
    ----------
    xaxis:np.ndarray
        The wavelength or pixel position values.
    flux: np.ndarray, array-like, list
        The extracted flux (measured intensity of light).
    calibrated: bool
        Flag to indicate calibration state. (Default = True.)
    header: astropy.Header, dict-like
        Header information of observation.

    """
    def __init__(self, flux=None, xaxis=None, calibrated=True, header=None, interp_method="spline"):
        """Initalise a Spectrum object."""

        # Some checks before creating class
        if isinstance(flux, str):
            raise TypeError("Cannot assign {} to the flux attribute".format(
                type(flux)))
        elif isinstance(xaxis, str):
            raise TypeError("Cannot assign {} to the xaxis attribute".format(
                type(xaxis)))

        if flux is not None:
            self._flux = np.asarray(flux)
        else:
            self._flux = flux

        if xaxis is None:
            if flux is None:
                self._xaxis = None
            else:
                # Applying range to xaxis of equal length of flux
                try:
                    self._xaxis = np.arange(len(flux))
                except TypeError:
                    print("TypeError caught because flux has no length")
                    self._xaxis = None
        else:
            self._xaxis = np.asarray(xaxis)  # Setter not used - need asarray

        # Check assigned lengths
        self.length_check()
        self.calibrated = calibrated
        if header is None:
            self.header = {}
        else:
            self.header = header   # Access header with a dictionary call.
        self.interp_method = interp_method

    @property
    def interp_method(self):
        """Getter for the interp_method attribute."""
        return self._interp_method

{'fraction_non_alphanumeric': 0.0801896960551843, 'fraction_numerical': 0.002155636990730761, 'mean_word_length': 2.0566534914361, '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': '3283895', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1185, 'n_words': 409}