Skip to content

Data Quality Rating

This part of the project documentation focuses on an information-oriented approach. Use it as a reference for the technical implementation of the pact_methodology project code.

Data Quality Ratings (DQRs) are used to assess the quality of data used in Pathfinder Framework calculations. These ratings are applied to different aspects of data quality, such as technological representativeness, temporal representativeness, geographical representativeness, completeness, and reliability.

Each DQR is represented as an integer value between 1 and 3 (inclusive), following the Pathfinder Framework guidelines. A higher DQR indicates higher data quality.

This module provides the DataQualityRating class to encapsulate and validate DQR values.

DataQualityRating dataclass

Represents a data quality rating for a specific aspect of data quality.

Attributes:

Name Type Description
rating int

The data quality rating, an integer between 1 and 3 (inclusive).

Examples:

>>> dqr = DataQualityRating(3)
>>> dqr.rating
3
>>> str(dqr)
'3'
Source code in pact_methodology/data_quality_indicators/data_quality_rating.py
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
71
72
73
74
75
76
77
78
79
80
@dataclass(eq=True, frozen=True)
class DataQualityRating:
    """
    Represents a data quality rating for a specific aspect of data quality.

    Attributes:
        rating (int): The data quality rating, an integer between 1 and 3 (inclusive).

    Examples:
        >>> dqr = DataQualityRating(3)
        >>> dqr.rating
        3
        >>> str(dqr)
        '3'
    """

    rating: int

    def __post_init__(self):
        """
        Validates the data quality rating upon initialization.

        Raises:
            TypeError: If the rating is not an integer.
            ValueError: If the rating is not between 1 and 3 (inclusive).

        Examples:
            >>> DataQualityRating(2)
            DataQualityRating(2)
            >>> DataQualityRating(4)
            Traceback (most recent call last):
            ...
            ValueError: Data quality rating must be between 1 and 3 (inclusive)
        """
        if not isinstance(self.rating, int):
            raise TypeError("Data quality rating must be an integer")
        if self.rating < 1 or self.rating > 3:
            raise ValueError("Data quality rating must be between 1 and 3 (inclusive)")

    def __str__(self):
        """
        Returns the string representation of the data quality rating.

        Returns:
            str: The string representation of the rating.

        Examples:
            >>> dqr = DataQualityRating(1)
            >>> str(dqr)
            '1'
        """
        return f"{self.rating}"

    def __repr__(self):
        """
        Returns the official string representation of the data quality rating.

        Returns:
            str: The official string representation of the rating.

        Examples:
            >>> dqr = DataQualityRating(2)
            >>> repr(dqr)
            'DataQualityRating(2)'
        """
        return f"DataQualityRating({self.rating})"

__post_init__()

Validates the data quality rating upon initialization.

Raises:

Type Description
TypeError

If the rating is not an integer.

ValueError

If the rating is not between 1 and 3 (inclusive).

Examples:

>>> DataQualityRating(2)
DataQualityRating(2)
>>> DataQualityRating(4)
Traceback (most recent call last):
...
ValueError: Data quality rating must be between 1 and 3 (inclusive)
Source code in pact_methodology/data_quality_indicators/data_quality_rating.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
def __post_init__(self):
    """
    Validates the data quality rating upon initialization.

    Raises:
        TypeError: If the rating is not an integer.
        ValueError: If the rating is not between 1 and 3 (inclusive).

    Examples:
        >>> DataQualityRating(2)
        DataQualityRating(2)
        >>> DataQualityRating(4)
        Traceback (most recent call last):
        ...
        ValueError: Data quality rating must be between 1 and 3 (inclusive)
    """
    if not isinstance(self.rating, int):
        raise TypeError("Data quality rating must be an integer")
    if self.rating < 1 or self.rating > 3:
        raise ValueError("Data quality rating must be between 1 and 3 (inclusive)")

__repr__()

Returns the official string representation of the data quality rating.

Returns:

Name Type Description
str

The official string representation of the rating.

Examples:

>>> dqr = DataQualityRating(2)
>>> repr(dqr)
'DataQualityRating(2)'
Source code in pact_methodology/data_quality_indicators/data_quality_rating.py
68
69
70
71
72
73
74
75
76
77
78
79
80
def __repr__(self):
    """
    Returns the official string representation of the data quality rating.

    Returns:
        str: The official string representation of the rating.

    Examples:
        >>> dqr = DataQualityRating(2)
        >>> repr(dqr)
        'DataQualityRating(2)'
    """
    return f"DataQualityRating({self.rating})"

__str__()

Returns the string representation of the data quality rating.

Returns:

Name Type Description
str

The string representation of the rating.

Examples:

>>> dqr = DataQualityRating(1)
>>> str(dqr)
'1'
Source code in pact_methodology/data_quality_indicators/data_quality_rating.py
54
55
56
57
58
59
60
61
62
63
64
65
66
def __str__(self):
    """
    Returns the string representation of the data quality rating.

    Returns:
        str: The string representation of the rating.

    Examples:
        >>> dqr = DataQualityRating(1)
        >>> str(dqr)
        '1'
    """
    return f"{self.rating}"