<commit_before>"""Definitions for the `SED` class."""
import numpy as np
from astropy import constants as c
from astropy import units as u
from mosfit.modules.module import Module

# Important: Only define one `Module` class per file.


class SED(Module):
    """Template class for SED Modules."""

    C_OVER_ANG = (c.c / u.Angstrom).cgs.value
    N_PTS = 16 + 1

    def __init__(self, **kwargs):
        """Initialize module."""
        super(SED, self).__init__(**kwargs)
        self._sample_wavelengths = []

    def receive_requests(self, **requests):
        """Receive requests from other `Module`s."""
        self._sample_wavelengths = requests.get('sample_wavelengths', [])
        if not self._sample_wavelengths:
            wave_ranges = requests.get('band_wave_ranges', [])
            if not wave_ranges:
                return
            for rng in wave_ranges:
                self._sample_wavelengths.append(
                    np.linspace(rng[0], rng[1], self.N_PTS))
            self._sample_wavelengths = np.array(self._sample_wavelengths)
        self._sample_frequencies = self.C_OVER_ANG / self._sample_wavelengths

    def add_to_existing_seds(self, new_seds, **kwargs):
        """Add SED from present module to existing `seds` key."""
        old_seds = kwargs.get('seds', None)
        if old_seds is not None:
            new_seds += old_seds
        return new_seds
<commit_msg>DOCS: testing function docstring for automodapi<commit_after>"""Definitions for the `SED` class."""
import numpy as np
from astropy import constants as c
from astropy import units as u
from mosfit.modules.module import Module

# Important: Only define one `Module` class per file.


class SED(Module):
    """Template class for SED Modules."""

    C_OVER_ANG = (c.c / u.Angstrom).cgs.value
    N_PTS = 16 + 1

    def __init__(self, **kwargs):
        """Initialize module."""
        super(SED, self).__init__(**kwargs)
        self._sample_wavelengths = []

    def receive_requests(self, **requests):
        """Receive requests from other `Module`s."""
        self._sample_wavelengths = requests.get('sample_wavelengths', [])
        if not self._sample_wavelengths:
            wave_ranges = requests.get('band_wave_ranges', [])
            if not wave_ranges:
                return
            for rng in wave_ranges:
                self._sample_wavelengths.append(
                    np.linspace(rng[0], rng[1], self.N_PTS))
            self._sample_wavelengths = np.array(self._sample_wavelengths)
        self._sample_frequencies = self.C_OVER_ANG / self._sample_wavelengths

    def add_to_existing_seds(self, new_seds, **kwargs):
        """Add SED from present module to existing ``seds`` key.

        Parameters
        ----------
        new_seds : array
            The new SEDs to add to the existing SEDs.

        Returns
        -------
        new_seds : array
            The result of summing the new and existing SEDs.
        """
        old_seds = kwargs.get('seds', None)
        if old_seds is not None:
            new_seds += old_seds
        return new_seds

{'fraction_non_alphanumeric': 0.10624597553122987, 'fraction_numerical': 0.003219575016097875, 'mean_word_length': 2.3993435448577682, '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': '3277979', 'n_tokens_mistral': 959, 'n_tokens_neox': 922, 'n_words': 251}