Skip to content

Commit

Permalink
Fix marginal modelling when all shares are NanS
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed Sep 11, 2023
1 parent d0b97c6 commit a3b9067
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion premise/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__all__ = ("NewDatabase", "clear_cache", "get_regions_definition")
__version__ = (1, 6, 7)
__version__ = (1, 6, 8)

from pathlib import Path

Expand Down
5 changes: 5 additions & 0 deletions premise/marginal_mixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ def consequential_method(data: xr.DataArray, year: int, args: dict) -> xr.DataAr
region=region, year=year
).sum(dim="variables")

# if shares contains only NaNs, we give its elements the value 1
if shares.isnull().all():
shares = xr.ones_like(shares)

time_parameters = {
(False, False, False, False): {
"start": year,
Expand Down Expand Up @@ -288,6 +292,7 @@ def consequential_method(data: xr.DataArray, year: int, args: dict) -> xr.DataAr
(bool(range_time), bool(duration), foresight, lead_time)
]["end_avg"]


except KeyError:
print(
f"The combination of range_time, duration, foresight, and lead_time {range_time, duration, foresight, lead_time} "
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def package_files(directory):

setup(
name="premise",
version="1.6.7",
version="1.6.8",
python_requires=">=3.9,<3.11",
packages=packages,
author="Romain Sacchi <[email protected]>, Alois Dirnaichner <[email protected]>, Chris Mutel "
Expand Down

0 comments on commit a3b9067

Please sign in to comment.