From 83ef07bd30387c264c913331959128b744eadf7b Mon Sep 17 00:00:00 2001 From: Philip Hackstock <20710924+phackstock@users.noreply.github.com> Date: Tue, 30 Jan 2024 15:10:43 +0100 Subject: [PATCH] Fix dict comprehension --- workflow.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/workflow.py b/workflow.py index 9f622e1..ab5eaf9 100644 --- a/workflow.py +++ b/workflow.py @@ -136,7 +136,6 @@ def _validate_meta( # validate meta columns for accepted values (if provided) or assign default for key, value in allowed_meta.items(): - # if the meta column exists, check that values are allowed if key in df.meta.columns: unknown = [v for v in df.meta[key].unique() if v not in value] @@ -153,11 +152,14 @@ def _validate_meta( return df + def kopernikus_public(df: pyam.IamDataFrame) -> pyam.IamDataFrame: definition = DataStructureDefinition(here / "definitions", dimensions=["region"]) - for region in definition.region.values(): - for synonym in ("abbr", "iso3"): - if synonym in region.extra_attributes: - rename_dict[region.extra_attributes[synonym]] = region.name + rename_dict = { + region.extra_attributes[synonym]: region.name + for region in definition.region.values() + for synonym in ("abbr", "iso3") + if synonym in region.extra_attributes + } return df.rename(region=rename_dict)