Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed Oct 6, 2023
2 parents 50f86c3 + 6cac167 commit cfcd577
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion premise/activity_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def generate_sets_from_filters(self, filtr: dict, database=None) -> dict:

# check if all keys have values
# if not, print warning
#for key, val in mapping.items():
# for key, val in mapping.items():
# if not val:
# print(f"Warning: No activities found for {key} -- revise mapping.")

Expand Down
3 changes: 1 addition & 2 deletions premise/ecoinvent_modification.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@
from .transport import _update_vehicles
from .utils import (
clear_existing_cache,
create_scenario_list,
eidb_label,
hide_messages,
info_on_utils_functions,
load_constants,
print_version,
warning_about_biogenic_co2,
write_brightway2_database,
create_scenario_list
)

DIR_CACHED_DB = DATA_DIR / "cache"
Expand Down Expand Up @@ -1590,7 +1590,6 @@ def write_db_to_simapro(self, filepath: str = None):
self.generate_change_report()

def write_datapackage(self, name: str = f"datapackage_{date.today()}"):

if not isinstance(name, str):
raise TypeError("`name` should be a string.")

Expand Down
20 changes: 10 additions & 10 deletions premise/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,10 +563,10 @@ def build_datapackage(df, inventories, list_scenarios, ei_version, name):
{
"name": s,
"description": f"Prospective db, "
f"based on {s.split(' - ')[0].upper()}, "
f"pathway {s.split(' - ')[1].upper()}, "
f"for the year {s.split(' - ')[2]}, and "
f"external scenario {' '.join(s.split(' - ')[3:])}.",
f"based on {s.split(' - ')[0].upper()}, "
f"pathway {s.split(' - ')[1].upper()}, "
f"for the year {s.split(' - ')[2]}, and "
f"external scenario {' '.join(s.split(' - ')[3:])}.",
}
for s in list_scenarios[1:]
]
Expand Down Expand Up @@ -596,11 +596,11 @@ def build_datapackage(df, inventories, list_scenarios, ei_version, name):


def generate_scenario_factor_file(
origin_db: list,
scenarios: dict,
db_name: str,
version: str,
scenario_list: list = None,
origin_db: list,
scenarios: dict,
db_name: str,
version: str,
scenario_list: list = None,
):
"""
Generate a scenario factor file from a list of databases
Expand Down Expand Up @@ -670,7 +670,7 @@ def generate_new_activities(args):


def generate_scenario_difference_file(
db_name,origin_db, scenarios, version, scenario_list
db_name, origin_db, scenarios, version, scenario_list
) -> tuple[DataFrame, list[dict], set[Any]]:
"""
Generate a scenario difference file for a given list of databases
Expand Down
4 changes: 3 additions & 1 deletion premise/external_data_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ def check_inventories(
and (i[0], i[1]) not in list_datasets
]

raise AssertionError(f"The following datasets are not in the inventory data: {list_missing_datasets}") from e
raise AssertionError(
f"The following datasets are not in the inventory data: {list_missing_datasets}"
) from e

# flag imported inventories
for i, dataset in enumerate(inventory_data):
Expand Down
9 changes: 4 additions & 5 deletions premise/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,17 +322,16 @@ def delete_log():


def create_scenario_list(scenarios, datapackages=None):

list_scenarios = [
f"{s['model']} - {s['pathway']} - {s['year']}" for s in scenarios
]
list_scenarios = [f"{s['model']} - {s['pathway']} - {s['year']}" for s in scenarios]

if "external scenarios" in scenarios[0]:
external_model_name = "External model"
for s, scenario in enumerate(scenarios):
for e, ext_scenario in enumerate(scenario["external scenarios"]):
if datapackages is not None:
external_model_name = datapackages[e].descriptor.get("name", "External model")
external_model_name = datapackages[e].descriptor.get(
"name", "External model"
)
list_scenarios[s] += f" - {external_model_name} - {ext_scenario}"

return list_scenarios

0 comments on commit cfcd577

Please sign in to comment.