Skip to content

Mutation Report

pyllmut.mutation_report.MutationReport

A report object that encapsulates the results of a mutant generation process.

Source code in pyllmut/mutation_report.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
class MutationReport:
    """
    A report object that encapsulates the results of a mutant generation process.
    """

    def __init__(
            self,
            mutant_list: List[MutantInfo],
            timeout_info_list: List[PromptInfo],
            bad_response_info_list: List[ResponseInfo]
    ):
        """
        Initializes a MutationReport object.

        Args:
            mutant_list (List[MutantInfo]): A list of MutantInfo objects representing the generated mutants.
            timeout_info_list (List[PromptInfo]): A list of PromptInfo objects for mutant generation attempts (for a line) that timed out.
            bad_response_info_list (List[ResponseInfo]): A list of ResponseInfo objects for mutant generation attempts (for a line) that model response is not parsable (bad JSON objects).
        """
        self._mutant_list = mutant_list
        self._timeout_info_list = timeout_info_list
        self._bad_response_info_list = bad_response_info_list

    def get_mutant_list(self) -> List[MutantInfo]:
        """
        Retrieves the complete list of generated mutants.

        Returns:
            List[MutantInfo]: A list of all MutantInfo objects.
        """
        return self._mutant_list

    def get_valid_mutant_list(self) -> List[MutantInfo]:
        """
        Returns only the valid mutants from the complete mutant list.
        A mutant is considered valid if its mutant type is equal to `MutantType.VALID`.

        Returns:
            List[MutantInfo]: A list of valid MutantInfo objects.
        """
        valid_mutant_list = [x for x in self._mutant_list
                             if x.get_mutant_type() == MutantType.VALID]

        return valid_mutant_list

    def get_timeout_info_list(self) -> List[PromptInfo]:
        """
        Retrieves the list of PromptInfo objects for mutant generation attempts (for a line) that timed out.

        Returns:
            List[PromptInfo]: A list of PromptInfo objects.
        """
        return self._timeout_info_list

    def get_bad_response_info_list(self) -> List[ResponseInfo]:
        """
        Retrieves the list of ResponseInfo objects for mutant generation attempts (for a line) that model response is not parsable (bad JSON objects).

        Returns:
            List[ResponseInfo]: A list of ResponseInfo objects.
        """
        return self._bad_response_info_list

get_bad_response_info_list()

Retrieves the list of ResponseInfo objects for mutant generation attempts (for a line) that model response is not parsable (bad JSON objects).

Returns:

Type Description
List[ResponseInfo]

List[ResponseInfo]: A list of ResponseInfo objects.

Source code in pyllmut/mutation_report.py
63
64
65
66
67
68
69
70
def get_bad_response_info_list(self) -> List[ResponseInfo]:
    """
    Retrieves the list of ResponseInfo objects for mutant generation attempts (for a line) that model response is not parsable (bad JSON objects).

    Returns:
        List[ResponseInfo]: A list of ResponseInfo objects.
    """
    return self._bad_response_info_list

get_mutant_list()

Retrieves the complete list of generated mutants.

Returns:

Type Description
List[MutantInfo]

List[MutantInfo]: A list of all MutantInfo objects.

Source code in pyllmut/mutation_report.py
32
33
34
35
36
37
38
39
def get_mutant_list(self) -> List[MutantInfo]:
    """
    Retrieves the complete list of generated mutants.

    Returns:
        List[MutantInfo]: A list of all MutantInfo objects.
    """
    return self._mutant_list

get_timeout_info_list()

Retrieves the list of PromptInfo objects for mutant generation attempts (for a line) that timed out.

Returns:

Type Description
List[PromptInfo]

List[PromptInfo]: A list of PromptInfo objects.

Source code in pyllmut/mutation_report.py
54
55
56
57
58
59
60
61
def get_timeout_info_list(self) -> List[PromptInfo]:
    """
    Retrieves the list of PromptInfo objects for mutant generation attempts (for a line) that timed out.

    Returns:
        List[PromptInfo]: A list of PromptInfo objects.
    """
    return self._timeout_info_list

get_valid_mutant_list()

Returns only the valid mutants from the complete mutant list. A mutant is considered valid if its mutant type is equal to MutantType.VALID.

Returns:

Type Description
List[MutantInfo]

List[MutantInfo]: A list of valid MutantInfo objects.

Source code in pyllmut/mutation_report.py
41
42
43
44
45
46
47
48
49
50
51
52
def get_valid_mutant_list(self) -> List[MutantInfo]:
    """
    Returns only the valid mutants from the complete mutant list.
    A mutant is considered valid if its mutant type is equal to `MutantType.VALID`.

    Returns:
        List[MutantInfo]: A list of valid MutantInfo objects.
    """
    valid_mutant_list = [x for x in self._mutant_list
                         if x.get_mutant_type() == MutantType.VALID]

    return valid_mutant_list