Skip to content

Commit

Permalink
Merge pull request #786 from rickecon/base_spend
Browse files Browse the repository at this point in the history
This PR fixes case in SS of baseline=True and baseline_spending=True
  • Loading branch information
jdebacker authored Feb 18, 2022
2 parents 7f8f384 + 393b5f6 commit 8ce4f4e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ogcore/default_parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -2985,8 +2985,8 @@
}
},
"baseline_spending": {
"title": "Flag to keep level of government spending and transfers constant between baseline and reform runs",
"description": "Flag to keep level of government spending and transfers constant between baseline and reform runs.",
"title": "Flag for use in reform simulations to keep level of government spending and transfers constant between baseline and reform runs",
"description": "Flag for use in reform simulations to keep level of government spending and transfers constant between baseline and reform runs.",
"section_1": "Fiscal Policy Parameters",
"section_2": "Spending",
"notes": "",
Expand Down
7 changes: 7 additions & 0 deletions ogcore/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ def compute_default_params(self):
None
'''
# Catch error if baseline_spending=True and baseline=True
if self.baseline_spending and self.baseline:
err_msg = (
'Parameter baseline_spending=True cannot coincide with ' +
'baseline=True.')
raise ValueError(err_msg)

# reshape lambdas
self.lambdas = self.lambdas.reshape(self.lambdas.shape[0], 1)
# cast integers as integers
Expand Down
5 changes: 3 additions & 2 deletions tests/test_SS.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,9 @@ def test_run_SS(tmpdir, baseline, param_updates, filename, dask_client):
baseline_dir=baseline_dir,
baseline=True,
num_workers=NUM_WORKERS)
p_base.update_specifications(param_updates)
p_base.baseline_spending = False
param_updates_base = param_updates.copy()
param_updates_base['baseline_spending'] = False
p_base.update_specifications(param_updates_base)
base_ss_outputs = SS.run_SS(p_base, client=dask_client)
utils.mkdirs(os.path.join(baseline_dir, "SS"))
ss_dir = os.path.join(baseline_dir, "SS", "SS_vars.pkl")
Expand Down

0 comments on commit 8ce4f4e

Please sign in to comment.