From c5e0789a6f0e28bb739af76009f4f63ade5dc950 Mon Sep 17 00:00:00 2001 From: Tom Bland Date: Wed, 7 May 2025 14:31:14 +0100 Subject: [PATCH 1/3] Fix small bug to get cache working --- src/muse/mca.py | 3 +-- src/muse/outputs/cache.py | 5 +---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/muse/mca.py b/src/muse/mca.py index 662e51ba..58025b70 100644 --- a/src/muse/mca.py +++ b/src/muse/mca.py @@ -336,8 +336,7 @@ def run(self) -> None: if year_idx == 0: self.outputs(self.market, self.sectors, year=current_year) self.outputs(self.market, self.sectors, year=investment_year) - self.outputs_cache.consolidate_cache(year=current_year) - # TODO: change cache to investment_year (not working properly anyway) + self.outputs_cache.consolidate_cache(year=investment_year) getLogger(__name__).info( f"Finished simulation period {current_year} to {investment_year} " diff --git a/src/muse/outputs/cache.py b/src/muse/outputs/cache.py index 5f77aa70..c76b2d4a 100644 --- a/src/muse/outputs/cache.py +++ b/src/muse/outputs/cache.py @@ -353,10 +353,7 @@ def extract_agents_internal( info[aid]["agent"] = agent.name info[aid]["category"] = agent.category info[aid]["sector"] = sector_name - info[aid]["dst_region"] = agent.region - info[aid]["year"] = agent.year - info[aid]["installed"] = agent.year - + info[aid]["region"] = agent.region return info From 11b37354f400bc6d354208c616bc230542068c55 Mon Sep 17 00:00:00 2001 From: Tom Bland Date: Wed, 7 May 2025 14:36:03 +0100 Subject: [PATCH 2/3] Revert a change --- src/muse/outputs/cache.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/muse/outputs/cache.py b/src/muse/outputs/cache.py index c76b2d4a..ac9b8fee 100644 --- a/src/muse/outputs/cache.py +++ b/src/muse/outputs/cache.py @@ -353,7 +353,7 @@ def extract_agents_internal( info[aid]["agent"] = agent.name info[aid]["category"] = agent.category info[aid]["sector"] = sector_name - info[aid]["region"] = agent.region + info[aid]["dst_region"] = agent.region return info From b54f368fb509d58265a2aa9728c2953262c248fc Mon Sep 17 00:00:00 2001 From: Tom Bland Date: Wed, 7 May 2025 14:41:28 +0100 Subject: [PATCH 3/3] Fix tests --- tests/test_outputs.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tests/test_outputs.py b/tests/test_outputs.py index 9a810578..10c0ab9d 100644 --- a/tests/test_outputs.py +++ b/tests/test_outputs.py @@ -480,8 +480,6 @@ def test_extract_agents_internal(newcapa_agent, retro_agent): "category", "sector", "dst_region", - "year", - "installed", ) assert actual[agent.uuid]["agent"] == agent.name assert actual[agent.uuid]["category"] == agent.category @@ -552,12 +550,8 @@ def test_consolidate_quantity(newcapa_agent, retro_agent): actual = consolidate_quantity(quantity, [a, b], agents) - cols = set( - (*agents[retro_agent.uuid].keys(), "installed", "year", "technology", quantity) - ) + cols = set((*agents[retro_agent.uuid].keys(), "technology", quantity)) assert set(actual.columns) == cols - assert all(actual.year == newcapa_agent.year) - assert all(actual.installed == newcapa_agent.year) assert all( name in (newcapa_agent.name, retro_agent.name) for name in actual.agent.unique() )