Skip to content

Commit

Permalink
print diffs for test that fails on GH
Browse files Browse the repository at this point in the history
  • Loading branch information
jdebacker committed Jun 22, 2021
1 parent dd0f7a9 commit 998ff41
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
7 changes: 7 additions & 0 deletions ogusa/tests/test_TPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,13 @@ def test_run_TPI(baseline, param_updates, filename, tmp_path,
test_dict = TPI.run_TPI(p, None)
expected_dict = utils.safe_read_pickle(filename)

for k, v in expected_dict.items():
print('Max diff in ', k, ' = ')
try:
print(np.absolute(test_dict[k][:p.T] - v[:p.T]).max())
except ValueError:
print(np.absolute(test_dict[k][:p.T, :, :] - v[:p.T, :, :]).max())

for k, v in expected_dict.items():
try:
assert(np.allclose(test_dict[k][:p.T], v[:p.T], rtol=1e-04,
Expand Down
3 changes: 2 additions & 1 deletion ogusa/tests/test_run_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
'''
import multiprocessing
import time
import os, sys
import os
import sys
import importlib.util
from pathlib import Path
import pytest
Expand Down
34 changes: 21 additions & 13 deletions run_examples/run_ogusa_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from ogusa import output_tables as ot
from ogusa import output_plots as op
from ogusa.execute import runner
from ogusa.parameters import Specifications
from ogusa.constants import REFORM_DIR, BASELINE_DIR
from ogusa.utils import safe_read_pickle

Expand Down Expand Up @@ -53,16 +54,18 @@ def main():
Run baseline policy first
------------------------------------------------------------------------
'''
tax_func_path = os.path.join(
CUR_DIR, '..', 'ogusa', 'data', 'tax_functions',
'TxFuncEst_baseline_CPS.pkl') # use cached baseline estimates
kwargs = {'output_base': base_dir, 'baseline_dir': base_dir,
'time_path': True, 'baseline': True,
'og_spec': og_spec, 'guid': '_example',
'client': client, 'num_workers': num_workers}
p = Specifications(
baseline=True,
client=client,
num_workers=num_workers,
baseline_dir=base_dir,
output_base=base_dir,
)
# Update parameters for baseline from default json file
p.update_specifications(og_spec)

start_time = time.time()
runner(**kwargs)
runner(p, time_path=True, client=client)
print('run time = ', time.time()-start_time)

'''
Expand All @@ -72,13 +75,18 @@ def main():
'''
# update the effective corporate income tax rate
og_spec = og_spec.update({'cit_rate': [0.35]})
kwargs = {'output_base': reform_dir, 'baseline_dir': base_dir,
'time_path': True, 'baseline': False,
'og_spec': og_spec, 'guid': '_example',
'client': client, 'num_workers': num_workers}
p2 = Specifications(
baseline=False,
client=client,
num_workers=num_workers,
baseline_dir=base_dir,
output_base=reform_dir,
)
# Update parameters for baseline from default json file
p2.update_specifications(og_spec)

start_time = time.time()
runner(**kwargs)
runner(p2, time_path=True, client=client)
print('run time = ', time.time()-start_time)

# return ans - the percentage changes in macro aggregates and prices
Expand Down

0 comments on commit 998ff41

Please sign in to comment.