Skip to content

Reference Period

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.

ReferencePeriod

Source code in pact_methodology/carbon_footprint/reference_period.py
 6
 7
 8
 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
class ReferencePeriod:

    def __init__(self, start: DateTime, end: DateTime):
        """Represents a reference period with a start and end date.

        Args:
            start: The start date of the reference period.
            end: The end date of the reference period.

        Raises:
            ValueError: If start date is not before end date, or if either date is not a DateTime object.
        """
        self.start = start
        self.end = end

    @property
    def start(self) -> DateTime:
        return self._start

    @start.setter
    def start(self, value: DateTime):
        if not isinstance(value, DateTime):
            raise ValueError("Start date must be a DateTime object")
        self._start = value

    @property
    def end(self) -> DateTime:
        return self._end

    @end.setter
    def end(self, value: DateTime):
        if not isinstance(value, DateTime):
            raise ValueError("End date must be a DateTime object")
        if self.start is not None and value <= self.start:
            raise ValueError("End date must be after start date")
        self._end = value

    def includes_2025_or_later(self) -> bool:
        """Checks if the reference period includes 2025 or later.

        Returns:
            bool: True if the end date of the reference period is in 2025 or later, False otherwise.
        """
        return self.end.year >= 2025

    def __repr__(self):
        return f"ReferencePeriod(start={self.start}, end={self.end})"

__init__(start, end)

Represents a reference period with a start and end date.

Parameters:

Name Type Description Default
start DateTime

The start date of the reference period.

required
end DateTime

The end date of the reference period.

required

Raises:

Type Description
ValueError

If start date is not before end date, or if either date is not a DateTime object.

Source code in pact_methodology/carbon_footprint/reference_period.py
 8
 9
10
11
12
13
14
15
16
17
18
19
def __init__(self, start: DateTime, end: DateTime):
    """Represents a reference period with a start and end date.

    Args:
        start: The start date of the reference period.
        end: The end date of the reference period.

    Raises:
        ValueError: If start date is not before end date, or if either date is not a DateTime object.
    """
    self.start = start
    self.end = end

includes_2025_or_later()

Checks if the reference period includes 2025 or later.

Returns:

Name Type Description
bool bool

True if the end date of the reference period is in 2025 or later, False otherwise.

Source code in pact_methodology/carbon_footprint/reference_period.py
43
44
45
46
47
48
49
def includes_2025_or_later(self) -> bool:
    """Checks if the reference period includes 2025 or later.

    Returns:
        bool: True if the end date of the reference period is in 2025 or later, False otherwise.
    """
    return self.end.year >= 2025