REGISTER NOW: Brightway Spring School! 🇨🇦 Québec City (Canada) 🗓️ 20.-24. May 2024

bw2data.backends.typos#

Module Contents#

Functions#

_check_keys(→ None)

Checks keys of a dictionary obj against a set of valid keys. If a key

_check_type(→ None)

Validates the type_value against a set of valid types. If the `type_value

Attributes#

VALID_ACTIVITY_KEYS

VALID_ACTIVITY_TYPES

VALID_EXCHANGE_KEYS

VALID_EXCHANGE_TYPES

check_activity_keys

check_activity_type

check_exchange_keys

check_exchange_type

bw2data.backends.typos._check_keys(obj: dict, kind: str, valid: Iterable[str]) None[source]#

Checks keys of a dictionary obj against a set of valid keys. If a key is a close match to any of the valid keys, a warning is raised indicating a possible incorrect key.

Parameters#

objdict

The dictionary whose keys are to be checked.

kindstr

The category of the keys being checked (e.g., ‘activity’, ‘exchange’).

validIterable[str]

An iterable of valid key values.

Raises#

UserWarning

Warns if a key in obj is not in valid but is close to a valid key.

Examples#

>>> _check_keys({"actvty": "value"}, "activity", ["activity", "process"])
Possible incorrect activity key found: Given `actvty` but `activity` is more common
bw2data.backends.typos._check_type(type_value: str, kind: str, valid: Iterable[str]) None[source]#

Validates the type_value against a set of valid types. If the `type_value is a close match (based on Damerau-Levenshtein distance) to any of the valid types a warning is raised indicating a possible typo.

Parameters#

type_valuestr

The type value to be checked.

kindstr

The category of the type being checked (e.g., ‘activity’, ‘exchange’).

validIterable[str]

An iterable of valid type values.

Raises#

UserWarning

Warns if type_value is not in valid but is close to a valid value.

Examples#

>>> _check_type("actvty", "activity", ["activity", "process"])
Possible typo found: Given activity type `actvty` but `activity` is more common
bw2data.backends.typos.VALID_ACTIVITY_KEYS = ('CAS number', 'activity', 'activity type', 'authors', 'categories', 'classifications', 'code',...[source]#
bw2data.backends.typos.VALID_ACTIVITY_TYPES = ('process', 'emission', 'natural resource', 'product', 'economic', 'inventory indicator')[source]#
bw2data.backends.typos.VALID_EXCHANGE_KEYS = ('activity', 'amount', 'classifications', 'comment', 'flow', 'input', 'loc', 'maximum',...[source]#
bw2data.backends.typos.VALID_EXCHANGE_TYPES = ('biosphere', 'production', 'substitution', 'generic production', 'technosphere', 'generic consumption')[source]#
bw2data.backends.typos.check_activity_keys[source]#
bw2data.backends.typos.check_activity_type[source]#
bw2data.backends.typos.check_exchange_keys[source]#
bw2data.backends.typos.check_exchange_type[source]#