diff --git a/premise/external.py b/premise/external.py index 865bb928..9a0d22df 100644 --- a/premise/external.py +++ b/premise/external.py @@ -5,6 +5,7 @@ import logging import uuid from collections import defaultdict +from functools import lru_cache from pathlib import Path from typing import List, Union @@ -14,7 +15,6 @@ import yaml from datapackage import Package from wurst import searching as ws -from functools import lru_cache from .activity_maps import InventorySet from .clean_datasets import get_biosphere_flow_uuid @@ -514,8 +514,6 @@ def regionalize_inventories(self, ds_names, regions, data: dict) -> None: self.write_log(act) self.add_to_index(act) - - # some datasets might be meant to replace the supply # of other datasets, so we need to adjust those replacing_acts = { @@ -912,14 +910,14 @@ def write_suppliers_exchanges(self, suppliers: dict, supply_share: float) -> lis @lru_cache() def add_additional_exchanges( - self, - name: str, - ref_prod: str, - categories: tuple, - unit: str, - amount: float, - region: str, - ei_version: str + self, + name: str, + ref_prod: str, + categories: tuple, + unit: str, + amount: float, + region: str, + ei_version: str, ) -> list: """ Add additional exchanges to a dataset. @@ -1244,12 +1242,16 @@ def create_markets(self) -> None: for additional_exc in market_vars["add"]: add_excs = self.add_additional_exchanges( name=additional_exc["name"], - ref_prod=additional_exc.get("reference product"), + ref_prod=additional_exc.get( + "reference product" + ), categories=additional_exc.get("categories"), unit=additional_exc.get("unit"), amount=additional_exc.get("amount"), region=region, - ei_version=dp.descriptor["ecoinvent"]["version"], + ei_version=dp.descriptor["ecoinvent"][ + "version" + ], ) new_market["exchanges"].extend(add_excs) diff --git a/premise/external_data_validation.py b/premise/external_data_validation.py index 04d7da4f..b30f8b10 100644 --- a/premise/external_data_validation.py +++ b/premise/external_data_validation.py @@ -54,7 +54,11 @@ def find_iam_efficiency_change( def flag_activities_to_adjust( - dataset: dict, scenario_data: dict, year: int, dataset_vars: dict, region_proxy_mapping=None + dataset: dict, + scenario_data: dict, + year: int, + dataset_vars: dict, + region_proxy_mapping=None, ) -> dict: """ Flag datasets that will need to be adjusted.