Skip to content

Commit

Permalink
Fix issue when creating only one World market
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed Jun 28, 2024
1 parent 3e6f50f commit caeb480
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion premise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"clear_inventory_cache",
"get_regions_definition",
)
__version__ = (2, 1, 1, "dev3")
__version__ = (2, 1, 1, "dev4")


from premise.new_database import NewDatabase
Expand Down
2 changes: 1 addition & 1 deletion premise/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ def create_markets(self) -> None:
]

# remove World region from regions
if "World" in regions:
if "World" in regions and len(regions) > 1:
regions.remove("World")

# Loop through regions
Expand Down
13 changes: 12 additions & 1 deletion premise/external_data_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,18 @@ def flag_activities_to_adjust(
:return: dataset with additional info on variables to adjust
"""

regions = scenario_data["production volume"].region.values.tolist()
if "production volume variable" not in dataset_vars:
regions = scenario_data["production volume"].region.values.tolist()
else:
data = scenario_data["production volume"].sel(
variables=dataset_vars["production volume variable"]
)
# fetch regions which do not contain nan data
regions = [
r for r in data.region.values.tolist()
if not np.isnan(data.sel(region=r).values).all()
]

if "except regions" in dataset_vars:
regions = [r for r in regions if r not in dataset_vars["except regions"]]

Expand Down

0 comments on commit caeb480

Please sign in to comment.