Closed duncanhobbs closed 5 years ago
@duncanhobbs Thanks for working on this. Before merging, I'll check that the subscripts referenced are correct. FYI (and it looks like you might have seen this already), but the notation is generally taken from the simple CGE model in the Hosoe, Gawana, and Hashimoto CGE text and also the slides from @DPrihardini here.
@jdebacker I have added a few more tests of the functions in firms.py
to this PR. I went though chapters 2 and 6 of the Hashimoto book pretty carefully to check that the notation is correct.
The only tests I did not add to the test_aggregates.py
, test_government.py
, and test_firms.py
scripts are the tests that require pulling data from the SAM and comparing it to output. I think those tests could be added to the execute.py script @rkasher wrote, which tests the output from the CGE model.
I kept placeholders for these tests to remind myself these functions need tests written, but I can take them out if you like.
Here is the output from my test sessions:
============================= test session starts =============================
platform win32 -- Python 3.7.3, pytest-4.4.0, py-1.8.0, pluggy-0.9.0
rootdir: C:\Users\duncan.hobbs\Github\PSL\CGE
plugins: xdist-1.26.1, pep8-1.0.6, forked-1.0.2
collected 15 items
test_firms.py ............... [100%]
========================== 15 passed in 0.90 seconds ==========================
(cge_env) C:\Users\duncan.hobbs\Github\PSL\CGE\open_cge\tests> pytest test_gover
nment.py
C:\Users\duncan.hobbs\AppData\Local\Continuum\anaconda3\envs\cge_env\lib\site-pa
ckages\pep8.py:110: FutureWarning: Possible nested set at position 1
EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[[({] | []}),;:]')
============================= test session starts =============================
platform win32 -- Python 3.7.3, pytest-4.4.0, py-1.8.0, pluggy-0.9.0
rootdir: C:\Users\duncan.hobbs\Github\PSL\CGE
plugins: xdist-1.26.1, pep8-1.0.6, forked-1.0.2
collected 5 items
test_government.py ..... [100%]
========================== 5 passed in 1.27 seconds ===========================
(cge_env) C:\Users\duncan.hobbs\Github\PSL\CGE\open_cge\tests> pytest test_aggre
gates.py
C:\Users\duncan.hobbs\AppData\Local\Continuum\anaconda3\envs\cge_env\lib\site-pa
ckages\pep8.py:110: FutureWarning: Possible nested set at position 1
EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[[({] | []}),;:]')
============================= test session starts =============================
platform win32 -- Python 3.7.3, pytest-4.4.0, py-1.8.0, pluggy-0.9.0
rootdir: C:\Users\duncan.hobbs\Github\PSL\CGE
plugins: xdist-1.26.1, pep8-1.0.6, forked-1.0.2
collected 6 items
test_aggregates.py ...... [100%]
========================== 6 passed in 0.74 seconds ===========================
In trying to fix the build error, I realized that there are new updates that I forgot to merge in earlier. To keep things clean, I will close this PR and open a new one from a new branch with all of the updates.
This pull request adds tests for several of the functions in
firms.py
,aggregates.py
, andgovernment.py
.I also added a few comments to the function docstrings.