Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for SAM matrix #37

Merged
merged 2 commits into from
Jul 26, 2019
Merged

Conversation

duncanhobbs
Copy link
Contributor

This PR adds tests for the SAM matrix mentioned in issue #7.

I added functions to execute.py to check that the matrix is square, that the rows and columns sum to the expected values, and that the row sums and column sums are equal.

test of execute.py

(cge_env) C:\Users\duncan.hobbs\Github\PSL\CGE\open_cge> python execute.py

Distance at iteration  1  is  4.121147867408581e-12
Model solved, Q =  AGR     116.0
OIL     149.0
IND    1432.0
SER    1803.0
dtype: float64

I also added tests of these functions to test_execute.py

test of test_execute.py

(cge_env) C:\Users\duncan.hobbs\Github\PSL\CGE\open_cge\tests> pytest test_execu
te.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_execute.py .....                                                    [100%]

============================== warnings summary ===============================
open_cge/tests/test_execute.py::test_runner
open_cge/tests/test_execute.py::test_runner
open_cge/tests/test_execute.py::test_runner
  C:\Users\duncan.hobbs\AppData\Local\Continuum\anaconda3\envs\cge_env\lib\site-
packages\numpy\lib\type_check.py:546: DeprecationWarning: np.asscalar(a) is depr
ecated since NumPy v1.16, use a.item() instead
    'a.item() instead', DeprecationWarning, stacklevel=1)

-- Docs: https://docs.pytest.org/en/latest/warnings.html
==================== 5 passed, 3 warnings in 1.72 seconds =====================

@jdebacker
Copy link
Member

Thanks @duncanhobbs !

@jdebacker jdebacker merged commit 7de2e5e into PSLmodels:master Jul 26, 2019
@duncanhobbs duncanhobbs deleted the sam-tests branch July 26, 2019 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants