Skip to content

Commit

Permalink
Make black
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhuppmann committed Nov 15, 2023
1 parent 09139e3 commit 88f4041
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pyam/ixmp4.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from ixmp4.core.region import RegionModel
from ixmp4.core.unit import UnitModel


def write_to_ixmp4(df, platform: ixmp4.Platform):
"""Save all scenarios as new default runs in an ixmp4 platform database instance
Expand All @@ -21,13 +22,13 @@ def write_to_ixmp4(df, platform: ixmp4.Platform):
# quickfix: ensure that units and regions exist before writing
for dimension, values, model in [
("regions", df.region, RegionModel),
("units", df.unit, UnitModel)
("units", df.unit, UnitModel),
]:
platform_values = platform.__getattribute__(dimension).tabulate().name.values
if missing := [i for i in values if i not in platform_values]:
raise model.NotFound(
", ".join(missing) +
f". Use `Platform.{dimension}.create()` to add the missing {dimension}."
", ".join(missing)
+ f". Use `Platform.{dimension}.create()` to add the missing {dimension}."
)

for model, scenario in df.index:
Expand All @@ -40,4 +41,4 @@ def write_to_ixmp4(df, platform: ixmp4.Platform):
run.meta[key] = int(value)
else:
run.meta[key] = value
run.set_as_default()
run.set_as_default()

0 comments on commit 88f4041

Please sign in to comment.