Skip to content

Emission Factor DS

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.

EmissionFactorDS

Represents an emission factor database reference.

This class represents references to emission factor databases as defined in Section 4.1.3.2 of the PACT Methodology.

Parameters:

Name Type Description Default
name str

The name of the emission factor database.

required
version str

The version of the emission factor database.

required

Raises:

Type Description
ValueError

If name or version is empty or not a string.

Examples:

Create an emission factor database reference: >>> ef_db = EmissionFactorDS(name="ecoinvent", version="3.9.1")

Convert to dictionary format: >>> ef_db.to_dict() {'name': 'ecoinvent', 'version': '3.9.1'}

Source code in pact_methodology/carbon_footprint/emission_factor_ds.py
  1
  2
  3
  4
  5
  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
 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
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
class EmissionFactorDS:
    """Represents an emission factor database reference.

    This class represents references to emission factor databases as defined in
    Section 4.1.3.2 of the PACT Methodology.

    Args:
        name (str): The name of the emission factor database.
        version (str): The version of the emission factor database.

    Raises:
        ValueError: If name or version is empty or not a string.

    Examples:
        Create an emission factor database reference:
            >>> ef_db = EmissionFactorDS(name="ecoinvent", version="3.9.1")

        Convert to dictionary format:
            >>> ef_db.to_dict()
            {'name': 'ecoinvent', 'version': '3.9.1'}
    """

    def __init__(self, name: str, version: str):
        """Initialize an EmissionFactorDS instance.

        Args:
            name: The name of the emission factor database
            version: The version of the emission factor database

        Raises:
            ValueError: If name or version is empty or not a string
        """
        self.name = name
        self.version = version

    @property
    def name(self) -> str:
        """Get the database name.

        Returns:
            str: The database name string
        """
        return self._name

    @name.setter
    def name(self, value: str):
        """Set the database name.

        Args:
            value: The database name string

        Raises:
            ValueError: If value is empty or not a string
        """
        if not isinstance(value, str) or not value:
            raise ValueError("name must be a non-empty string")
        self._name = value

    @property
    def version(self) -> str:
        """Get the database version.

        Returns:
            str: The database version string
        """
        return self._version

    @version.setter
    def version(self, value: str):
        """Set the database version.

        Args:
            value: The database version string

        Raises:
            ValueError: If value is empty or not a string
        """
        if not isinstance(value, str) or not value:
            raise ValueError("version must be a non-empty string")
        self._version = value

    def to_dict(self) -> dict:
        """Convert to a dictionary representation.

        Returns:
            dict: A dictionary with the following structure:
                {
                    "name": str,  # The database name
                    "version": str  # The database version
                }

        Example:
            >>> ef_ds = EmissionFactorDS(name="ecoinvent", version="3.9.1")
            >>> ef_ds.to_dict()
            {'name': 'ecoinvent', 'version': '3.9.1'}
        """
        return {
            "name": self.name,
            "version": self.version
        }

    def __str__(self) -> str:
        """Get string representation.

        Returns:
            str: A human-readable string showing the attributes
        """
        return f"name={self.name}, version={self.version}"

    def __repr__(self) -> str:
        """Get detailed string representation.

        Returns:
            str: A string that could be used to recreate the object
        """
        return f"EmissionFactorDS(name='{self.name}', version='{self.version}')"

    def __eq__(self, other) -> bool:
        """Check equality with another instance.

        Args:
            other: The other instance to compare with

        Returns:
            bool: True if equal, False otherwise
        """
        if not isinstance(other, EmissionFactorDS):
            return False
        return self.name == other.name and self.version == other.version

name property writable

Get the database name.

Returns:

Name Type Description
str str

The database name string

version property writable

Get the database version.

Returns:

Name Type Description
str str

The database version string

__eq__(other)

Check equality with another instance.

Parameters:

Name Type Description Default
other

The other instance to compare with

required

Returns:

Name Type Description
bool bool

True if equal, False otherwise

Source code in pact_methodology/carbon_footprint/emission_factor_ds.py
118
119
120
121
122
123
124
125
126
127
128
129
def __eq__(self, other) -> bool:
    """Check equality with another instance.

    Args:
        other: The other instance to compare with

    Returns:
        bool: True if equal, False otherwise
    """
    if not isinstance(other, EmissionFactorDS):
        return False
    return self.name == other.name and self.version == other.version

__init__(name, version)

Initialize an EmissionFactorDS instance.

Parameters:

Name Type Description Default
name str

The name of the emission factor database

required
version str

The version of the emission factor database

required

Raises:

Type Description
ValueError

If name or version is empty or not a string

Source code in pact_methodology/carbon_footprint/emission_factor_ds.py
23
24
25
26
27
28
29
30
31
32
33
34
def __init__(self, name: str, version: str):
    """Initialize an EmissionFactorDS instance.

    Args:
        name: The name of the emission factor database
        version: The version of the emission factor database

    Raises:
        ValueError: If name or version is empty or not a string
    """
    self.name = name
    self.version = version

__repr__()

Get detailed string representation.

Returns:

Name Type Description
str str

A string that could be used to recreate the object

Source code in pact_methodology/carbon_footprint/emission_factor_ds.py
110
111
112
113
114
115
116
def __repr__(self) -> str:
    """Get detailed string representation.

    Returns:
        str: A string that could be used to recreate the object
    """
    return f"EmissionFactorDS(name='{self.name}', version='{self.version}')"

__str__()

Get string representation.

Returns:

Name Type Description
str str

A human-readable string showing the attributes

Source code in pact_methodology/carbon_footprint/emission_factor_ds.py
102
103
104
105
106
107
108
def __str__(self) -> str:
    """Get string representation.

    Returns:
        str: A human-readable string showing the attributes
    """
    return f"name={self.name}, version={self.version}"

to_dict()

Convert to a dictionary representation.

Returns:

Name Type Description
dict dict

A dictionary with the following structure: { "name": str, # The database name "version": str # The database version }

Example

ef_ds = EmissionFactorDS(name="ecoinvent", version="3.9.1") ef_ds.to_dict() {'name': 'ecoinvent', 'version': '3.9.1'}

Source code in pact_methodology/carbon_footprint/emission_factor_ds.py
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
def to_dict(self) -> dict:
    """Convert to a dictionary representation.

    Returns:
        dict: A dictionary with the following structure:
            {
                "name": str,  # The database name
                "version": str  # The database version
            }

    Example:
        >>> ef_ds = EmissionFactorDS(name="ecoinvent", version="3.9.1")
        >>> ef_ds.to_dict()
        {'name': 'ecoinvent', 'version': '3.9.1'}
    """
    return {
        "name": self.name,
        "version": self.version
    }