Skip to content

Commit

Permalink
Fix dict comprehension
Browse files Browse the repository at this point in the history
  • Loading branch information
phackstock committed Jan 30, 2024
1 parent 9c41847 commit 83ef07b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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)

0 comments on commit 83ef07b

Please sign in to comment.