• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

iprafols / stacking / 10923202860

18 Sep 2024 01:29PM UTC coverage: 99.247% (-0.8%) from 100.0%
10923202860

push

github

iprafols
yapfed and linted code

499 of 505 branches covered (98.81%)

Branch coverage included in aggregate %.

3 of 3 new or added lines in 3 files covered. (100.0%)

8 existing lines in 3 files now uncovered.

1345 of 1353 relevant lines covered (99.41%)

2.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.26
/stacking/stacker.py
1
""" Basic structure for stackers """
2
import numpy as np
3✔
3

4
from stacking.errors import StackerError
3✔
5
from stacking.spectrum import Spectrum
3✔
6

7
accepted_options = []
3✔
8
required_options = []
3✔
9
defaults = {}
3✔
10

11

12
class Stacker:
3✔
13
    """Abstract class to define the normalizer skeleton
14

15
    Methods
16
    -------
17
    __init__
18
    stack
19

20
    Attributes
21
    ----------
22
    stacked_flux: array of float
23
    The stacked flux
24

25
    stacked_weight: array of float
26
    The sum of weights associated with each flux
27
    """
28

29
    def __init__(self, config):  # pylint: disable=unused-argument
3✔
30
        """Initialize class instance
31

32
        Arguments
33
        ---------
34
        config: configparser.SectionProxy
35
        Ignored, passed here to have consistent inheritance calls
36

37
        Raise
38
        -----
39
        StackerError if the selected reading mode is not supported
40
        """
41

42
        # initialize results
43
        if Spectrum.common_wavelength_grid is None:
3✔
44
            raise StackerError(
3✔
45
                "Spectrum.common_wavelength_grid must be set to initialize any "
46
                "Stacker instances")
47
        self.stacked_flux = np.zeros(Spectrum.common_wavelength_grid.size)
3✔
48
        self.stacked_error = np.zeros(Spectrum.common_wavelength_grid.size)
3✔
49
        self.stacked_weight = np.zeros(Spectrum.common_wavelength_grid.size)
3✔
50

51
    def set_stacked_error(self, stacked_error):
3✔
52
        """ Set the stacked error
53

54
        Arguments
55
        ---------
56
        stacked_error: np.array
57
        The stacked error
58

59
        Raise
60
        -----
61
        StackerError if the shape of the passed array does not match the
62
        existing array
63
        """
UNCOV
64
        if stacked_error.shape != self.stacked_error.shape:
×
UNCOV
65
            raise StackerError(
×
66
                "Invalid array when attempting to set the stack error. Shapes "
67
                f"do not match. Expected {self.stacked_error.shape}. Found "
68
                f"{stacked_error.shape}")
UNCOV
69
        self.stacked_error = stacked_error
×
70

71
    def stack(self, spectra):
3✔
72
        """ Stack spectra
73

74
        Arguments
75
        ---------
76
        spectra: list of Spectrum
77
        The spectra to stack
78

79
        Raise
80
        -----
81
        StackerError if function was not overloaded by child class
82
        """
83
        raise StackerError("Method 'stack' was not overloaded by child class")
3✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc