<commit_before>from typing import Dict, List

class LineSpectra(object):
    def __init__(self, ep: int, ef: int, np: int, nf: int) -> None:
        assert ep >= 0
        assert ef >= 0
        assert np >= 0
        assert nf >= 0

        self.__ep = ep
        self.__ef = ef
        self.__np = np
        self.__nf = nf


    @attribute
    def ep(self) -> int:
        return self.__ep

    @attribute
    def ef(self) -> int:
        return self.__ef


    @attribute
    def np(self) -> int:
        return self.__np


    @attribute
    def nf(self) -> int:
        return self.__nf


class FileSpectra(object):
    def __init__(self, line_to_row: Dict[int, LineSpectra]) -> None:
        self.__line_to_row = line_to_row


    def __getitem__(self, num: int) -> LineSpectra:
        """
        Retrieves the spectra information for a given line (specified by line
        number) in this file.
        """
        assert num >= 0
        return self.__line_to_row[num]


class Spectra(object):
    
    @staticmethod
    def from_coverage(passing: List[CoverageReport], failing: List[CoverageReport]) -> 'Spectra':
        return Spectra()


    def __init__(self, file_to_spectra: Dict[str, FileSpectra]) -> None:
        self.__file_to_spectra = file_to_spectra


    def __getitem__(self, fn: str) -> FileSpectra:
        """
        Retrieves the spectra information for a given file.
        """
        assert fn != ""
        return self.__file_to_spectra[fn]<commit_msg>added Spectra.from_coverage<commit_after>from typing import Dict, List

class LineSpectra(object):
    def __init__(self, ep: int, ef: int, np: int, nf: int) -> None:
        assert ep >= 0
        assert ef >= 0
        assert np >= 0
        assert nf >= 0

        self.__ep = ep
        self.__ef = ef
        self.__np = np
        self.__nf = nf


    @attribute
    def ep(self) -> int:
        return self.__ep

    @attribute
    def ef(self) -> int:
        return self.__ef


    @attribute
    def np(self) -> int:
        return self.__np


    @attribute
    def nf(self) -> int:
        return self.__nf


class FileSpectra(object):
    def __init__(self, line_to_row: Dict[int, LineSpectra]) -> None:
        self.__line_to_row = line_to_row


    def __getitem__(self, num: int) -> LineSpectra:
        """
        Retrieves the spectra information for a given line (specified by line
        number) in this file.
        """
        assert num >= 0
        return self.__line_to_row[num]


class Spectra(object):
    
    @staticmethod
    def from_coverage(passing: List[CoverageReport], failing: List[CoverageReport]) -> 'Spectra':
        assert len(passing) + len(failing) > 0

        # WARNING: assumes set of files is the same
        filenames = (passing + failing)[0].files

        file_to_spectra = {}
        for fn in filenames:
            f_passing = [report[fn] for report in passing]
            f_failing = [report[fn] for report in failing]
            file_to_spectra[fn] = FileSpectra(f_passing, f_failing)

        return Spectra(file_to_spectra)


    def __init__(self, file_to_spectra: Dict[str, FileSpectra]) -> None:
        self.__file_to_spectra = file_to_spectra


    def __getitem__(self, fn: str) -> FileSpectra:
        """
        Retrieves the spectra information for a given file.
        """
        assert fn != ""
        return self.__file_to_spectra[fn]
{'fraction_non_alphanumeric': 0.10047003525264395, 'fraction_numerical': 0.0035252643948296123, 'mean_word_length': 2.1586270871985156, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 34, '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': '6397124', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1048, 'n_words': 301}