Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/muse/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def next(
)

# Calculate investments
investments = self.invest(
result = self.invest(
search=search[["search_space", "decision"]],
technologies=technologies,
constraints=constraints,
Expand All @@ -373,7 +373,7 @@ def next(
# Add investments
self.add_investments(
technologies=technologies,
investments=investments,
investments=result["capacity"].rename("investment"),
investment_year=investment_year,
)

Expand Down
28 changes: 17 additions & 11 deletions src/muse/investments.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,22 @@ def decorated(
**kwargs,
)

if isinstance(result, xr.Dataset):
investment = result["capacity"].rename("investment")
if "production" in result:
cache_quantity(production=result["production"])
else:
investment = result.rename("investment")

cache_quantity(capacity=investment)

return investment
# Check the output
assert set(result.data_vars) == {"capacity", "production"}
assert set(result.capacity.dims) == {"asset", "replacement"}
assert set(result.production.dims) == {
"asset",
"replacement",
"commodity",
"timeslice",
}

# Add to cache
cache_quantity(production=result["production"])
cache_quantity(capacity=result["capacity"])

# Return the result
return result

return decorated

Expand Down Expand Up @@ -158,7 +164,7 @@ def compute_investment(
constraints=constraints,
**params,
**kwargs,
).rename("investment")
)

return compute_investment

Expand Down
Loading