Skip to content

Parse pheval result

parse_pheval_result(data_class_type, pheval_result)

Parse PhEval result into specified dataclass type.

Parameters:

Name Type Description Default
data_class_type PhEvalResult

The data class type to parse the result into.

required
pheval_result List[dict]

A list of dictionaries representing the PhEval result.

required

Returns:

Type Description
List[PhEvalResult]

List[PhEvalResult]: A list of instances of the specified data class type,

List[PhEvalResult]

each instance representing a row in the PhEval result.

Source code in src/pheval/analyse/parse_pheval_result.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
def parse_pheval_result(
    data_class_type: PhEvalResult, pheval_result: List[dict]
) -> List[PhEvalResult]:
    """
    Parse PhEval result into specified dataclass type.

    Args:
        data_class_type (PhEvalResult): The data class type to parse the result into.
        pheval_result (List[dict]): A list of dictionaries representing the PhEval result.

    Returns:
        List[PhEvalResult]: A list of instances of the specified data class type,
        each instance representing a row in the PhEval result.
    """
    return [data_class_type(**row) for row in pheval_result]

read_standardised_result(standardised_result_path)

Read the standardised result output and return a list of dictionaries.

Parameters:

Name Type Description Default
standardised_result_path Path

The path to the file containing the standardised result output.

required

Returns:

Type Description
List[dict]

List[dict]: A list of dictionaries representing the content of the standardised result file.

Source code in src/pheval/analyse/parse_pheval_result.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
def read_standardised_result(standardised_result_path: Path) -> List[dict]:
    """
    Read the standardised result output and return a list of dictionaries.

    Args:
        standardised_result_path (Path): The path to the file containing the standardised result output.

    Returns:
        List[dict]: A list of dictionaries representing the content of the standardised result file.
    """
    if standardised_result_path.is_file():
        return pd.read_csv(standardised_result_path, delimiter="\t").to_dict("records")
    else:
        info_log.info(f"Could not find {standardised_result_path}")
        return pd.DataFrame().to_dict("records")