Skip to content

Assurance

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.

Assurance

Represents an assurance in conformance with PACT Methodology chapter 5 and appendix B.

This class represents the assurance information for a product carbon footprint calculation, including details about the assurance provider, coverage, level, and other relevant metadata.

Attributes:

Name Type Description
assurance bool

A boolean flag indicating whether the CarbonFootprint has been assured in line with PACT Methodology requirements (section 5).

provider_name str

The non-empty name of the independent third party engaged to undertake the assurance.

coverage Coverage | None

Level of granularity of the emissions data assured.

level Level | None

Level of assurance applicable to the PCF.

boundary Boundary | None

Boundary of the assurance.

completed_at DateTime | None

The date at which the assurance was completed.

standard_name str | None

Name of the standard against which the PCF was assured.

comments str | None

Any additional comments that will clarify the interpretation of the assurance.

Examples:

Create a basic assurance record:

>>> assurance = Assurance(
...     assurance=True,
...     provider_name="Assurance Corp"
... )

Create a detailed assurance record:

>>> from pact_methodology.datetime import DateTime
>>> detailed = Assurance(
...     assurance=True,
...     provider_name="Assurance Corp",
...     coverage=Coverage.PRODUCT_LEVEL,
...     level=Level.REASONABLE,
...     boundary=Boundary.CRADLE_TO_GATE,
...     completed_at=DateTime(2023, 1, 1),
...     standard_name="ISO 14064-3:2019",
...     comments="Full product lifecycle assessment"
... )

Convert assurance to dictionary format:

>>> assurance.to_dict()
{
    'assurance': True,
    'provider_name': 'Assurance Corp'
}

Raises:

Type Description
ValueError

If assurance is not a boolean, if provider_name is not a string, if coverage is not None and not an instance of Coverage, if level is not None and not an instance of Level, if boundary is not None and not an instance of Boundary, if completed_at is not None and not an instance of DateTime, if standard_name is not None and not a string, if comments is not None and not a string.

TypeError

If required arguments are missing during initialization.

Note

Only assurance and provider_name are required fields. All other attributes are optional but must conform to their specified types when provided.

Source code in pact_methodology/assurance/assurance.py
 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
class Assurance:
    """Represents an assurance in conformance with PACT Methodology chapter 5 and appendix B.

    This class represents the assurance information for a product carbon footprint calculation,
    including details about the assurance provider, coverage, level, and other relevant metadata.

    Attributes:
        assurance (bool): A boolean flag indicating whether the CarbonFootprint has been assured in line 
            with PACT Methodology requirements (section 5).
        provider_name (str): The non-empty name of the independent third party engaged to undertake 
            the assurance.
        coverage (Coverage | None): Level of granularity of the emissions data assured.
        level (Level | None): Level of assurance applicable to the PCF.
        boundary (Boundary | None): Boundary of the assurance.
        completed_at (DateTime | None): The date at which the assurance was completed.
        standard_name (str | None): Name of the standard against which the PCF was assured.
        comments (str | None): Any additional comments that will clarify the interpretation of the assurance.

    Examples:
        Create a basic assurance record:
        >>> assurance = Assurance(
        ...     assurance=True,
        ...     provider_name="Assurance Corp"
        ... )

        Create a detailed assurance record:
        >>> from pact_methodology.datetime import DateTime
        >>> detailed = Assurance(
        ...     assurance=True,
        ...     provider_name="Assurance Corp",
        ...     coverage=Coverage.PRODUCT_LEVEL,
        ...     level=Level.REASONABLE,
        ...     boundary=Boundary.CRADLE_TO_GATE,
        ...     completed_at=DateTime(2023, 1, 1),
        ...     standard_name="ISO 14064-3:2019",
        ...     comments="Full product lifecycle assessment"
        ... )

        Convert assurance to dictionary format:
        >>> assurance.to_dict()
        {
            'assurance': True,
            'provider_name': 'Assurance Corp'
        }

    Raises:
        ValueError: If assurance is not a boolean, if provider_name is not a string,
            if coverage is not None and not an instance of Coverage,
            if level is not None and not an instance of Level,
            if boundary is not None and not an instance of Boundary,
            if completed_at is not None and not an instance of DateTime,
            if standard_name is not None and not a string,
            if comments is not None and not a string.
        TypeError: If required arguments are missing during initialization.

    Note:
        Only assurance and provider_name are required fields. All other attributes are optional
        but must conform to their specified types when provided.
    """

    def __init__(
        self,
        assurance: bool,
        provider_name: str,
        coverage: Coverage | None = None,
        level: Level | None = None,
        boundary: Boundary | None = None,
        completed_at: DateTime | None = None,
        standard_name: str | None = None,
        comments: str | None = None,
    ):
        """Initialize an Assurance instance.

        Args:
            assurance: Boolean indicating if CarbonFootprint is assured
            provider_name: Name of the assurance provider
            coverage: Level of granularity of assured emissions data
            level: Level of assurance for the PCF
            boundary: Boundary of the assurance
            completed_at: Date of assurance completion
            standard_name: Name of assurance standard used
            comments: Additional clarifying comments

        Raises:
            ValueError: If arguments are invalid
            TypeError: If required arguments are missing
        """
        self.assurance = assurance
        self.provider_name = provider_name
        self.coverage = coverage
        self.level = level
        self.boundary = boundary
        self.completed_at = completed_at
        self.standard_name = standard_name
        self.comments = comments

    @property
    def assurance(self) -> bool:
        """Get the assurance flag.

        Returns:
            The boolean assurance status
        """
        return self._assurance

    @assurance.setter
    def assurance(self, value: bool):
        """Set the assurance flag.

        Args:
            value: The boolean assurance status to set

        Raises:
            ValueError: If value is not a boolean
        """
        if not isinstance(value, bool):
            raise ValueError("assurance must be a boolean")
        self._assurance = value

    @property
    def provider_name(self) -> str:
        """Get the assurance provider name.

        Returns:
            The provider name string
        """
        return self._provider_name

    @provider_name.setter
    def provider_name(self, value: str):
        """Set the assurance provider name.

        Args:
            value: The provider name string to set

        Raises:
            ValueError: If value is not a string
        """
        if not isinstance(value, str):
            raise ValueError("provider_name must be a string")
        self._provider_name = value

    @property
    def coverage(self) -> Coverage | None:
        """Get the assurance coverage level.

        Returns:
            The Coverage enum value or None
        """
        return self._coverage

    @coverage.setter
    def coverage(self, value: Coverage | None):
        """Set the assurance coverage level.

        Args:
            value: The Coverage enum value to set or None

        Raises:
            ValueError: If value is not None and not a Coverage enum
        """
        if value is not None and not isinstance(value, Coverage):
            raise ValueError("coverage must be an instance of Coverage")
        self._coverage = value

    @property
    def level(self) -> Level | None:
        """Get the assurance level.

        Returns:
            The Level enum value or None
        """
        return self._level

    @level.setter
    def level(self, value: Level | None):
        """Set the assurance level.

        Args:
            value: The Level enum value to set or None

        Raises:
            ValueError: If value is not None and not a Level enum
        """
        if value is not None and not isinstance(value, Level):
            raise ValueError("level must be an instance of Level")
        self._level = value

    @property
    def boundary(self) -> Boundary | None:
        """Get the assurance boundary.

        Returns:
            The Boundary enum value or None
        """
        return self._boundary

    @boundary.setter
    def boundary(self, value: Boundary | None):
        """Set the assurance boundary.

        Args:
            value: The Boundary enum value to set or None

        Raises:
            ValueError: If value is not None and not a Boundary enum
        """
        if value is not None and not isinstance(value, Boundary):
            raise ValueError("boundary must be an instance of Boundary")
        self._boundary = value

    @property
    def completed_at(self) -> DateTime | None:
        """Get the assurance completion date.

        Returns:
            The DateTime instance or None
        """
        return self._completed_at

    @completed_at.setter
    def completed_at(self, value: DateTime | None):
        """Set the assurance completion date.

        Args:
            value: The DateTime instance to set or None

        Raises:
            ValueError: If value is not None and not a DateTime instance
        """
        if value is not None and not isinstance(value, DateTime):
            raise ValueError("completed_at must be an instance of DateTime")
        self._completed_at = value

    @property
    def standard_name(self) -> str | None:
        """Get the assurance standard name.

        Returns:
            The standard name string or None
        """
        return self._standard_name

    @standard_name.setter
    def standard_name(self, value: str | None):
        """Set the assurance standard name.

        Args:
            value: The standard name string to set or None

        Raises:
            ValueError: If value is not None and not a string
        """
        if value is not None and not isinstance(value, str):
            raise ValueError("standard_name must be a string")
        self._standard_name = value

    @property
    def comments(self) -> str | None:
        """Get the assurance comments.

        Returns:
            The comments string or None
        """
        return self._comments

    @comments.setter
    def comments(self, value: str | None):
        """Set the assurance comments.

        Args:
            value: The comments string to set or None

        Raises:
            ValueError: If value is not None and not a string
        """
        if value is not None and not isinstance(value, str):
            raise ValueError("comments must be a string")
        self._comments = value

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

        Returns:
            A dictionary with the following structure:
            {
                "assurance": bool,  # The assurance status
                "provider_name": str,  # Name of assurance provider
                "coverage": str | None,  # Coverage level if set
                "level": str | None,  # Assurance level if set
                "boundary": str | None,  # Assurance boundary if set
                "completed_at": str | None,  # Completion date if set
                "standard_name": str | None,  # Standard name if set
                "comments": str | None  # Comments if set
            }
        """
        assurance_dict = {
            "assurance": self.assurance,
            "provider_name": self.provider_name,
        }

        if self.coverage is not None:
            assurance_dict["coverage"] = self.coverage.value

        if self.level is not None:
            assurance_dict["level"] = self.level.value

        if self.boundary is not None:
            assurance_dict["boundary"] = self.boundary.value

        if self.completed_at is not None:
            assurance_dict["completed_at"] = str(self.completed_at)

        if self.standard_name is not None:
            assurance_dict["standard_name"] = self.standard_name

        if self.comments is not None:
            assurance_dict["comments"] = self.comments

        return assurance_dict

    def __str__(self):
        return (
            f"Assurance("
            f"assurance={self.assurance}, "
            f"provider_name='{self.provider_name}', "
            f"coverage={self.coverage}, "
            f"level={self.level}, "
            f"boundary={self.boundary}, "
            f"completed_at={self.completed_at}, "
            f"standard_name='{self.standard_name}', "
            f"comments='{self.comments}')"
        )

    def __repr__(self):
        return (
            f"Assurance("
            f"assurance={self.assurance}, "
            f"provider_name='{self.provider_name}', "
            f"coverage={self.coverage}, "
            f"level={self.level}, "
            f"boundary={self.boundary}, "
            f"completed_at={self.completed_at}, "
            f"standard_name='{self.standard_name}', "
            f"comments='{self.comments}')"
        )

    def __eq__(self, other):
        return self.__dict__ == other.__dict__

assurance: bool property writable

Get the assurance flag.

Returns:

Type Description
bool

The boolean assurance status

boundary: Boundary | None property writable

Get the assurance boundary.

Returns:

Type Description
Boundary | None

The Boundary enum value or None

comments: str | None property writable

Get the assurance comments.

Returns:

Type Description
str | None

The comments string or None

completed_at: DateTime | None property writable

Get the assurance completion date.

Returns:

Type Description
DateTime | None

The DateTime instance or None

coverage: Coverage | None property writable

Get the assurance coverage level.

Returns:

Type Description
Coverage | None

The Coverage enum value or None

level: Level | None property writable

Get the assurance level.

Returns:

Type Description
Level | None

The Level enum value or None

provider_name: str property writable

Get the assurance provider name.

Returns:

Type Description
str

The provider name string

standard_name: str | None property writable

Get the assurance standard name.

Returns:

Type Description
str | None

The standard name string or None

__init__(assurance, provider_name, coverage=None, level=None, boundary=None, completed_at=None, standard_name=None, comments=None)

Initialize an Assurance instance.

Parameters:

Name Type Description Default
assurance bool

Boolean indicating if CarbonFootprint is assured

required
provider_name str

Name of the assurance provider

required
coverage Coverage | None

Level of granularity of assured emissions data

None
level Level | None

Level of assurance for the PCF

None
boundary Boundary | None

Boundary of the assurance

None
completed_at DateTime | None

Date of assurance completion

None
standard_name str | None

Name of assurance standard used

None
comments str | None

Additional clarifying comments

None

Raises:

Type Description
ValueError

If arguments are invalid

TypeError

If required arguments are missing

Source code in pact_methodology/assurance/assurance.py
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
130
131
132
133
134
135
def __init__(
    self,
    assurance: bool,
    provider_name: str,
    coverage: Coverage | None = None,
    level: Level | None = None,
    boundary: Boundary | None = None,
    completed_at: DateTime | None = None,
    standard_name: str | None = None,
    comments: str | None = None,
):
    """Initialize an Assurance instance.

    Args:
        assurance: Boolean indicating if CarbonFootprint is assured
        provider_name: Name of the assurance provider
        coverage: Level of granularity of assured emissions data
        level: Level of assurance for the PCF
        boundary: Boundary of the assurance
        completed_at: Date of assurance completion
        standard_name: Name of assurance standard used
        comments: Additional clarifying comments

    Raises:
        ValueError: If arguments are invalid
        TypeError: If required arguments are missing
    """
    self.assurance = assurance
    self.provider_name = provider_name
    self.coverage = coverage
    self.level = level
    self.boundary = boundary
    self.completed_at = completed_at
    self.standard_name = standard_name
    self.comments = comments

to_dict()

Convert the assurance to a dictionary representation.

Returns:

Type Description
dict

A dictionary with the following structure:

dict

{ "assurance": bool, # The assurance status "provider_name": str, # Name of assurance provider "coverage": str | None, # Coverage level if set "level": str | None, # Assurance level if set "boundary": str | None, # Assurance boundary if set "completed_at": str | None, # Completion date if set "standard_name": str | None, # Standard name if set "comments": str | None # Comments if set

dict

}

Source code in pact_methodology/assurance/assurance.py
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
def to_dict(self) -> dict:
    """Convert the assurance to a dictionary representation.

    Returns:
        A dictionary with the following structure:
        {
            "assurance": bool,  # The assurance status
            "provider_name": str,  # Name of assurance provider
            "coverage": str | None,  # Coverage level if set
            "level": str | None,  # Assurance level if set
            "boundary": str | None,  # Assurance boundary if set
            "completed_at": str | None,  # Completion date if set
            "standard_name": str | None,  # Standard name if set
            "comments": str | None  # Comments if set
        }
    """
    assurance_dict = {
        "assurance": self.assurance,
        "provider_name": self.provider_name,
    }

    if self.coverage is not None:
        assurance_dict["coverage"] = self.coverage.value

    if self.level is not None:
        assurance_dict["level"] = self.level.value

    if self.boundary is not None:
        assurance_dict["boundary"] = self.boundary.value

    if self.completed_at is not None:
        assurance_dict["completed_at"] = str(self.completed_at)

    if self.standard_name is not None:
        assurance_dict["standard_name"] = self.standard_name

    if self.comments is not None:
        assurance_dict["comments"] = self.comments

    return assurance_dict