Skip to content

Commit

Permalink
add infrastructure for PDS1, PDS2, PDS3
Browse files Browse the repository at this point in the history
Changes to solution extraction, solution factory, solution tests and documentation to generate, use and test the new PDS1, PDS2 and PDS3 fields .
  • Loading branch information
denised committed Aug 17, 2021
1 parent 3b5fd2f commit 1afe724
Show file tree
Hide file tree
Showing 89 changed files with 654 additions and 1,635 deletions.
368 changes: 140 additions & 228 deletions Start_Here.ipynb

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions solution/afforestation/tests/test_afforestation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
TEST_SKIP = None

def test_afforestation_loader():
"""Test that the solution can load a single scenario"""
(constructor,scenarios) = factory.one_solution_scenarios(solution_name)
assert len(scenarios) > 0
ascenario = constructor(scenarios[0])
assert ascenario is not None
"""Test that the solution can load the defined scenarios"""
pds1 = factory.solution_pds_type(solution_name,"PDS1")
pds2 = factory.solution_pds_type(solution_name,"PDS2")
pds3 = factory.solution_pds_type(solution_name, "PDS3")
assert pds1 and pds2 and pds3

@pytest.mark.slow
def test_afforestation_results(scenario_skip=None, test_skip=None, test_only=None):
Expand Down
10 changes: 5 additions & 5 deletions solution/airplanes/tests/test_airplanes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
TEST_SKIP = None

def test_airplanes_loader():
"""Test that the solution can load a single scenario"""
(constructor,scenarios) = factory.one_solution_scenarios(solution_name)
assert len(scenarios) > 0
ascenario = constructor(scenarios[0])
assert ascenario is not None
"""Test that the solution can load the defined scenarios"""
pds1 = factory.solution_pds_type(solution_name,"PDS1")
pds2 = factory.solution_pds_type(solution_name,"PDS2")
pds3 = factory.solution_pds_type(solution_name, "PDS3")
assert pds1 and pds2 and pds3

@pytest.mark.slow
def test_airplanes_results(scenario_skip=None, test_skip=None, test_only=None):
Expand Down
10 changes: 5 additions & 5 deletions solution/altcement/tests/test_altcement.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
TEST_SKIP = None

def test_altcement_loader():
"""Test that the solution can load a single scenario"""
(constructor,scenarios) = factory.one_solution_scenarios(solution_name)
assert len(scenarios) > 0
ascenario = constructor(scenarios[0])
assert ascenario is not None
"""Test that the solution can load the defined scenarios"""
pds1 = factory.solution_pds_type(solution_name,"PDS1")
pds2 = factory.solution_pds_type(solution_name,"PDS2")
pds3 = factory.solution_pds_type(solution_name, "PDS3")
assert pds1 and pds2 and pds3

@pytest.mark.slow
def test_altcement_results(scenario_skip=None, test_skip=None, test_only=None):
Expand Down
10 changes: 5 additions & 5 deletions solution/bamboo/tests/test_bamboo.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
TEST_SKIP = None

def test_bamboo_loader():
"""Test that the solution can load a single scenario"""
(constructor,scenarios) = factory.one_solution_scenarios(solution_name)
assert len(scenarios) > 0
ascenario = constructor(scenarios[0])
assert ascenario is not None
"""Test that the solution can load the defined scenarios"""
pds1 = factory.solution_pds_type(solution_name,"PDS1")
pds2 = factory.solution_pds_type(solution_name,"PDS2")
pds3 = factory.solution_pds_type(solution_name, "PDS3")
assert pds1 and pds2 and pds3

@pytest.mark.slow
def test_bamboo_results(scenario_skip=None, test_skip=None, test_only=None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
"EU": 0.0,
"USA": 0.0
},
"soln_pds_adoption_custom_name": "(OPT2) Drawdown Team projections based on a weighted average of Several Sources",
"soln_pds_adoption_custom_name": "(PDS2) Drawdown Team projections based on a weighted average of Several Sources",
"soln_ref_adoption_basis": "Custom",
"soln_ref_adoption_custom_name": "Drawdown Book Ed.1 Reference Scenario",
"soln_ref_adoption_regional_data": false,
Expand Down
2 changes: 2 additions & 0 deletions solution/bikeinfrastructure/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
8/2021
Fixed load failure that occurred because the Adoption had been renamed; corrected the name in the scenario.
10 changes: 5 additions & 5 deletions solution/bikeinfrastructure/tests/test_bikeinfrastructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
TEST_SKIP = None

def test_bikeinfrastructure_loader():
"""Test that the solution can load a single scenario"""
(constructor,scenarios) = factory.one_solution_scenarios(solution_name)
assert len(scenarios) > 0
ascenario = constructor(scenarios[0])
assert ascenario is not None
"""Test that the solution can load the defined scenarios"""
pds1 = factory.solution_pds_type(solution_name,"PDS1")
pds2 = factory.solution_pds_type(solution_name,"PDS2")
pds3 = factory.solution_pds_type(solution_name, "PDS3")
assert pds1 and pds2 and pds3

@pytest.mark.slow
def test_bikeinfrastructure_results(scenario_skip=None, test_skip=None, test_only=None):
Expand Down
10 changes: 5 additions & 5 deletions solution/biochar/tests/test_biochar.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
TEST_SKIP = None

def test_biochar_loader():
"""Test that the solution can load a single scenario"""
(constructor,scenarios) = factory.one_solution_scenarios(solution_name)
assert len(scenarios) > 0
ascenario = constructor(scenarios[0])
assert ascenario is not None
"""Test that the solution can load the defined scenarios"""
pds1 = factory.solution_pds_type(solution_name,"PDS1")
pds2 = factory.solution_pds_type(solution_name,"PDS2")
pds3 = factory.solution_pds_type(solution_name, "PDS3")
assert pds1 and pds2 and pds3

@pytest.mark.slow
def test_biochar_results(scenario_skip=None, test_skip=None, test_only=None):
Expand Down
10 changes: 5 additions & 5 deletions solution/biogas/tests/test_biogas.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
TEST_SKIP = None

def test_biogas_loader():
"""Test that the solution can load a single scenario"""
(constructor,scenarios) = factory.one_solution_scenarios(solution_name)
assert len(scenarios) > 0
ascenario = constructor(scenarios[0])
assert ascenario is not None
"""Test that the solution can load the defined scenarios"""
pds1 = factory.solution_pds_type(solution_name,"PDS1")
pds2 = factory.solution_pds_type(solution_name,"PDS2")
pds3 = factory.solution_pds_type(solution_name, "PDS3")
assert pds1 and pds2 and pds3

@pytest.mark.slow
def test_biogas_results(scenario_skip=None, test_skip=None, test_only=None):
Expand Down
10 changes: 5 additions & 5 deletions solution/biogas_small/tests/test_biogas_small.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
TEST_SKIP = None

def test_biogas_small_loader():
"""Test that the solution can load a single scenario"""
(constructor,scenarios) = factory.one_solution_scenarios(solution_name)
assert len(scenarios) > 0
ascenario = constructor(scenarios[0])
assert ascenario is not None
"""Test that the solution can load the defined scenarios"""
pds1 = factory.solution_pds_type(solution_name,"PDS1")
pds2 = factory.solution_pds_type(solution_name,"PDS2")
pds3 = factory.solution_pds_type(solution_name, "PDS3")
assert pds1 and pds2 and pds3

@pytest.mark.slow
def test_biogas_small_results(scenario_skip=None, test_skip=None, test_only=None):
Expand Down
10 changes: 5 additions & 5 deletions solution/biomass/tests/test_biomass.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
TEST_SKIP = None

def test_biomass_loader():
"""Test that the solution can load a single scenario"""
(constructor,scenarios) = factory.one_solution_scenarios(solution_name)
assert len(scenarios) > 0
ascenario = constructor(scenarios[0])
assert ascenario is not None
"""Test that the solution can load the defined scenarios"""
pds1 = factory.solution_pds_type(solution_name,"PDS1")
pds2 = factory.solution_pds_type(solution_name,"PDS2")
pds3 = factory.solution_pds_type(solution_name, "PDS3")
assert pds1 and pds2 and pds3

@pytest.mark.slow
def test_biomass_results(scenario_skip=None, test_skip=None, test_only=None):
Expand Down
10 changes: 5 additions & 5 deletions solution/bioplastic/tests/test_bioplastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
TEST_SKIP = None

def test_bioplastic_loader():
"""Test that the solution can load a single scenario"""
(constructor,scenarios) = factory.one_solution_scenarios(solution_name)
assert len(scenarios) > 0
ascenario = constructor(scenarios[0])
assert ascenario is not None
"""Test that the solution can load the defined scenarios"""
pds1 = factory.solution_pds_type(solution_name,"PDS1")
pds2 = factory.solution_pds_type(solution_name,"PDS2")
pds3 = factory.solution_pds_type(solution_name, "PDS3")
assert pds1 and pds2 and pds3

@pytest.mark.slow
def test_bioplastic_results(scenario_skip=None, test_skip=None, test_only=None):
Expand Down
10 changes: 5 additions & 5 deletions solution/buildingautomation/tests/test_buildingautomation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
TEST_SKIP = None

def test_buildingautomation_loader():
"""Test that the solution can load a single scenario"""
(constructor,scenarios) = factory.one_solution_scenarios(solution_name)
assert len(scenarios) > 0
ascenario = constructor(scenarios[0])
assert ascenario is not None
"""Test that the solution can load the defined scenarios"""
pds1 = factory.solution_pds_type(solution_name,"PDS1")
pds2 = factory.solution_pds_type(solution_name,"PDS2")
pds3 = factory.solution_pds_type(solution_name, "PDS3")
assert pds1 and pds2 and pds3

@pytest.mark.slow
def test_buildingautomation_results(scenario_skip=None, test_skip=None, test_only=None):
Expand Down
10 changes: 5 additions & 5 deletions solution/carpooling/tests/test_carpooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
TEST_SKIP = None

def test_carpooling_loader():
"""Test that the solution can load a single scenario"""
(constructor,scenarios) = factory.one_solution_scenarios(solution_name)
assert len(scenarios) > 0
ascenario = constructor(scenarios[0])
assert ascenario is not None
"""Test that the solution can load the defined scenarios"""
pds1 = factory.solution_pds_type(solution_name,"PDS1")
pds2 = factory.solution_pds_type(solution_name,"PDS2")
pds3 = factory.solution_pds_type(solution_name, "PDS3")
assert pds1 and pds2 and pds3

@pytest.mark.slow
def test_carpooling_results(scenario_skip=None, test_skip=None, test_only=None):
Expand Down
10 changes: 5 additions & 5 deletions solution/composting/tests/test_composting.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
TEST_SKIP = None

def test_composting_loader():
"""Test that the solution can load a single scenario"""
(constructor,scenarios) = factory.one_solution_scenarios(solution_name)
assert len(scenarios) > 0
ascenario = constructor(scenarios[0])
assert ascenario is not None
"""Test that the solution can load the defined scenarios"""
pds1 = factory.solution_pds_type(solution_name,"PDS1")
pds2 = factory.solution_pds_type(solution_name,"PDS2")
pds3 = factory.solution_pds_type(solution_name, "PDS3")
assert pds1 and pds2 and pds3

@pytest.mark.slow
def test_composting_results(scenario_skip=None, test_skip=None, test_only=None):
Expand Down
10 changes: 5 additions & 5 deletions solution/concentratedsolar/tests/test_concentratedsolar.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
TEST_SKIP = None

def test_concentratedsolar_loader():
"""Test that the solution can load a single scenario"""
(constructor,scenarios) = factory.one_solution_scenarios(solution_name)
assert len(scenarios) > 0
ascenario = constructor(scenarios[0])
assert ascenario is not None
"""Test that the solution can load the defined scenarios"""
pds1 = factory.solution_pds_type(solution_name,"PDS1")
pds2 = factory.solution_pds_type(solution_name,"PDS2")
pds3 = factory.solution_pds_type(solution_name, "PDS3")
assert pds1 and pds2 and pds3

@pytest.mark.slow
def test_concentratedsolar_results(scenario_skip=None, test_skip=None, test_only=None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
TEST_SKIP = None

def test_conservationagriculture_loader():
"""Test that the solution can load a single scenario"""
(constructor,scenarios) = factory.one_solution_scenarios(solution_name)
assert len(scenarios) > 0
ascenario = constructor(scenarios[0])
assert ascenario is not None
"""Test that the solution can load the defined scenarios"""
pds1 = factory.solution_pds_type(solution_name,"PDS1")
pds2 = factory.solution_pds_type(solution_name,"PDS2")
pds3 = factory.solution_pds_type(solution_name, "PDS3")
assert pds1 and pds2 and pds3

@pytest.mark.slow
def test_conservationagriculture_results(scenario_skip=None, test_skip=None, test_only=None):
Expand Down
10 changes: 5 additions & 5 deletions solution/coolroofs/tests/test_coolroofs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
TEST_SKIP = None

def test_coolroofs_loader():
"""Test that the solution can load a single scenario"""
(constructor,scenarios) = factory.one_solution_scenarios(solution_name)
assert len(scenarios) > 0
ascenario = constructor(scenarios[0])
assert ascenario is not None
"""Test that the solution can load the defined scenarios"""
pds1 = factory.solution_pds_type(solution_name,"PDS1")
pds2 = factory.solution_pds_type(solution_name,"PDS2")
pds3 = factory.solution_pds_type(solution_name, "PDS3")
assert pds1 and pds2 and pds3

@pytest.mark.slow
def test_coolroofs_results(scenario_skip=None, test_skip=None, test_only=None):
Expand Down
10 changes: 5 additions & 5 deletions solution/districtheating/tests/test_districtheating.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
TEST_SKIP = None

def test_districtheating_loader():
"""Test that the solution can load a single scenario"""
(constructor,scenarios) = factory.one_solution_scenarios(solution_name)
assert len(scenarios) > 0
ascenario = constructor(scenarios[0])
assert ascenario is not None
"""Test that the solution can load the defined scenarios"""
pds1 = factory.solution_pds_type(solution_name,"PDS1")
pds2 = factory.solution_pds_type(solution_name,"PDS2")
pds3 = factory.solution_pds_type(solution_name, "PDS3")
assert pds1 and pds2 and pds3

@pytest.mark.slow
def test_districtheating_results(scenario_skip=None, test_skip=None, test_only=None):
Expand Down
10 changes: 5 additions & 5 deletions solution/electricbikes/tests/test_electricbikes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
TEST_SKIP = None

def test_electricbikes_loader():
"""Test that the solution can load a single scenario"""
(constructor,scenarios) = factory.one_solution_scenarios(solution_name)
assert len(scenarios) > 0
ascenario = constructor(scenarios[0])
assert ascenario is not None
"""Test that the solution can load the defined scenarios"""
pds1 = factory.solution_pds_type(solution_name,"PDS1")
pds2 = factory.solution_pds_type(solution_name,"PDS2")
pds3 = factory.solution_pds_type(solution_name, "PDS3")
assert pds1 and pds2 and pds3

@pytest.mark.slow
def test_electricbikes_results(scenario_skip=None, test_skip=None, test_only=None):
Expand Down
6 changes: 3 additions & 3 deletions solution/electricvehicles/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@

# These are the "default" scenarios to use for each of the drawdown categories.
# They should be set to the most recent "official" set"
PDS1 = "PDS1-3p2050_Based on Navigant, Bloomberg (Book Ed.1)"
PDS2 = "PDS2-5p2050_Based on ITDP/UCD (Book Ed.1)"
PDS3 = "PDS3-6p2050_Growth to 6.5% (Book Ed.1)"
PDS1 = "PDS1-16p2050-with IEA 2DS (Integrated)"
PDS2 = "PDS2-23p2050-using IEA B2DS (Integrated)"
PDS3 = "PDS3-18p2050-Survival Analysis (Integrated)"

class Scenario(scenario.Scenario):
name = name
Expand Down
10 changes: 5 additions & 5 deletions solution/electricvehicles/tests/test_electricvehicles.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
TEST_SKIP = None

def test_electricvehicles_loader():
"""Test that the solution can load a single scenario"""
(constructor,scenarios) = factory.one_solution_scenarios(solution_name)
assert len(scenarios) > 0
ascenario = constructor(scenarios[0])
assert ascenario is not None
"""Test that the solution can load the defined scenarios"""
pds1 = factory.solution_pds_type(solution_name,"PDS1")
pds2 = factory.solution_pds_type(solution_name,"PDS2")
pds3 = factory.solution_pds_type(solution_name, "PDS3")
assert pds1 and pds2 and pds3

@pytest.mark.slow
def test_electricvehicles_results(scenario_skip=None, test_skip=None, test_only=None):
Expand Down
21 changes: 21 additions & 0 deletions solution/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,29 @@ def one_solution_scenarios(solution):
return (m.Scenario, list(m.scenarios.keys()))


def solution_pds_type(solution, pds_type):
"""Return the standard scenario for solution of type pds_type, where pds_type is one of
'PDS1', 'PDS2', 'PDS3'"""
importname = 'solution.' + solution
m = importlib.import_module(importname)
if pds_type == "PDS1":
return m.Scenario(m.PDS1)
if pds_type == "PDS2":
return m.Scenario(m.PDS2)
if pds_type == "PDS3":
return m.Scenario(m.PDS3)
raise ValueError("Scenario type not one of 'PDS1', 'PDS2' or 'PDS3'")


def all_solutions_scenarios():
everything = {}
for solution in all_solutions():
everything[solution] = one_solution_scenarios(solution)
return everything


def all_solutions_scenario_type(scenario_type):
everything = {}
for solution in all_solutions():
everything[solution] = solution_pds_type(scenario_type)
return everything
10 changes: 5 additions & 5 deletions solution/farmlandrestoration/tests/test_farmlandrestoration.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
TEST_SKIP = None

def test_farmlandrestoration_loader():
"""Test that the solution can load a single scenario"""
(constructor,scenarios) = factory.one_solution_scenarios(solution_name)
assert len(scenarios) > 0
ascenario = constructor(scenarios[0])
assert ascenario is not None
"""Test that the solution can load the defined scenarios"""
pds1 = factory.solution_pds_type(solution_name,"PDS1")
pds2 = factory.solution_pds_type(solution_name,"PDS2")
pds3 = factory.solution_pds_type(solution_name, "PDS3")
assert pds1 and pds2 and pds3

@pytest.mark.slow
def test_farmlandrestoration_results(scenario_skip=None, test_skip=None, test_only=None):
Expand Down
Loading

0 comments on commit 1afe724

Please sign in to comment.