Skip to content

Commit

Permalink
More test cleanups
Browse files Browse the repository at this point in the history
Get rid of excess scenarios
  • Loading branch information
denised committed Oct 25, 2021
1 parent 9db0c20 commit ba3b8ef
Show file tree
Hide file tree
Showing 120 changed files with 35 additions and 15,236 deletions.
23 changes: 0 additions & 23 deletions model/tests/test_operatingcost.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,29 +562,6 @@ def test_annual_breakout_zero_cost_zero_lifetime_replacement():
assert (result == 0).all(axis=None)


def test_annual_breakout_nonzero_cost_zero_lifetime_replacement():
soln_net_annual_funits_adopted = pd.DataFrame(soln_net_annual_funits_adopted_list[1:],
columns=soln_net_annual_funits_adopted_list[0]).set_index('Year')
soln_pds_tot_iunits_reqd = pd.DataFrame(soln_pds_tot_iunits_reqd_list[1:],
columns=soln_pds_tot_iunits_reqd_list[0]).set_index('Year')
soln_ref_tot_iunits_reqd = pd.DataFrame(soln_ref_tot_iunits_reqd_list[1:],
columns=soln_ref_tot_iunits_reqd_list[0]).set_index('Year')
ac = advanced_controls.AdvancedControls(report_end_year=2050,
soln_lifetime_capacity=0, soln_avg_annual_use=1725.04615384615,
soln_var_oper_cost_per_funit=0.0, soln_fuel_cost_per_funit=0.0,
soln_fixed_oper_cost_per_iunit=2)
oc = operatingcost.OperatingCost(ac=ac,
soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
conv_ref_annual_tot_iunits=None, soln_pds_annual_world_first_cost=None,
soln_ref_annual_world_first_cost=None, conv_ref_annual_world_first_cost=None,
single_iunit_purchase_year=None, soln_pds_install_cost_per_iunit=None,
conv_ref_install_cost_per_iunit=None, conversion_factor=1.0)
with pytest.raises(AssertionError):
result = oc.soln_pds_annual_breakout()


def test_soln_pds_annual_breakout_land():
columns = ['World', 'A']
index = range(2015, 2061)
Expand Down
44 changes: 0 additions & 44 deletions model/tests/test_unitadoption.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,50 +311,6 @@ def test_soln_pds_cumulative_funits_bug_behavior():
pd.testing.assert_frame_equal(result.iloc[0:5], expected, check_exact=False)


def test_soln_pds_cumulative_funits_bug_behavior_ref_base_adoption():
funits = [
['Year', 'World', 'OECD90', 'Eastern Europe', 'Asia (Sans Japan)', 'Middle East and Africa',
'Latin America', 'China', 'India', 'EU', 'USA'],
[2014, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.99],
[2015, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[2016, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[2017, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]]
soln_pds_funits_adopted = pd.DataFrame(funits[1:], columns=funits[0]).set_index('Year')
ac = advanced_controls.AdvancedControls(solution_category=SOLUTION_CATEGORY.LAND,
ref_base_adoption={ "World": 10.0, "OECD90": 9.0, "Eastern Europe": 8.0,
"Asia (Sans Japan)": 7.0, "Middle East and Africa": 6.0, "Latin America": 5.0,
"China": 4.0, "India": 3.0, "EU": 2.0, "USA": 1.0})
ua = unitadoption.UnitAdoption(ac=ac,
ref_total_adoption_units=None, pds_total_adoption_units=None,
soln_pds_funits_adopted=soln_pds_funits_adopted, soln_ref_funits_adopted=None,
bug_cfunits_double_count=True)
result = ua.soln_pds_cumulative_funits()
assert result.loc[2014, 'World'] == pytest.approx(0.1)
assert result.loc[2014, 'OECD90'] == pytest.approx(9.2)
assert result.loc[2014, 'Eastern Europe'] == pytest.approx(8.3)
assert result.loc[2014, 'Asia (Sans Japan)'] == pytest.approx(7.4)
assert result.loc[2014, 'Middle East and Africa'] == pytest.approx(6.5)
assert result.loc[2014, 'Latin America'] == pytest.approx(5.6)
assert result.loc[2014, 'China'] == pytest.approx(4.7)
assert result.loc[2014, 'India'] == pytest.approx(3.8)
assert result.loc[2014, 'EU'] == pytest.approx(2.9)
assert result.loc[2014, 'USA'] == pytest.approx(1.99)
ua = unitadoption.UnitAdoption(ac=ac,
ref_total_adoption_units=None, pds_total_adoption_units=None,
soln_pds_funits_adopted=soln_pds_funits_adopted, soln_ref_funits_adopted=None,
bug_cfunits_double_count=False)
result = ua.soln_pds_cumulative_funits()
assert result.loc[2014, 'World'] == pytest.approx(0.1)
assert result.loc[2014, 'OECD90'] == pytest.approx(0.2)
assert result.loc[2014, 'Eastern Europe'] == pytest.approx(0.3)
assert result.loc[2014, 'Asia (Sans Japan)'] == pytest.approx(0.4)
assert result.loc[2014, 'Middle East and Africa'] == pytest.approx(0.5)
assert result.loc[2014, 'Latin America'] == pytest.approx(0.6)
assert result.loc[2014, 'China'] == pytest.approx(0.7)
assert result.loc[2014, 'India'] == pytest.approx(0.8)
assert result.loc[2014, 'EU'] == pytest.approx(0.9)
assert result.loc[2014, 'USA'] == pytest.approx(0.99)


def test_soln_pds_cumulative_funits_missing_data():
funits = [
Expand Down
8 changes: 1 addition & 7 deletions model/unitadoption.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,7 @@ def soln_pds_cumulative_funits(self):
# the 2014 soln_pds_cumulative_funits, which ends up double counting 2014.
# We optionally enable this bug-for-bug compatibility.
# https://docs.google.com/document/d/19sq88J_PXY-y_EnqbSJDl0v9CdJArOdFLatNNUFhjEA/edit#heading=h.z9hqutnbnigx
idx = first_year.first_valid_index()
if self.ac is not None and self.ac.ref_base_adoption is not None:
# solutions updated for Drawdown 2020 have a ref_base_adoption dict
omit_main = pd.DataFrame(self.ac.ref_base_adoption, index=[idx])
else:
# Solutions not yet updated fall back to the original code here
omit_main = self.soln_pds_funits_adopted.iloc[[0], :].fillna(0.0).copy(deep=True)
omit_main = self.soln_pds_funits_adopted.iloc[[0], :].fillna(0.0).copy(deep=True)
omit_main.index.name = 'Year'
main_region = dd.REGIONS[0]
omit_main[main_region] = 0.0
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit ba3b8ef

Please sign in to comment.