-
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #401 from jdebacker/test_demog
Tests for demographics.py
- Loading branch information
Showing
9 changed files
with
88 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import numpy as np | ||
import pytest | ||
from ogusa import demographics | ||
|
||
|
||
def test_get_pop_objs(): | ||
""" | ||
Test of the that omega_SS and the last period of omega_path_S are | ||
close to each other. | ||
""" | ||
E = 20 | ||
S = 80 | ||
T = int(round(4.0 * S)) | ||
start_year = 2018 | ||
|
||
(omega, g_n_ss, omega_SS, surv_rate, rho, g_n_vector, imm_rates, | ||
omega_S_preTP) = demographics.get_pop_objs(E, S, T, 1, 100, | ||
start_year, False) | ||
|
||
assert (np.allclose(omega_SS, omega[-1, :])) | ||
|
||
|
||
def test_pop_smooth(): | ||
""" | ||
Test that population growth rates evolve smoothly. | ||
""" | ||
E = 20 | ||
S = 80 | ||
T = int(round(4.0 * S)) | ||
start_year = 2018 | ||
|
||
(omega, g_n_ss, omega_SS, surv_rate, rho, g_n_vector, imm_rates, | ||
omega_S_preTP) = demographics.get_pop_objs(E, S, T, 1, 100, | ||
start_year, False) | ||
|
||
assert (np.any(np.absolute(omega[:-1, :] - omega[1:, :]) < 0.0001)) | ||
assert (np.any(np.absolute(g_n_vector[:-1] - g_n_vector[1:]) < 0.0001)) | ||
|
||
|
||
def test_imm_smooth(): | ||
""" | ||
Test that population growth rates evolve smoothly. | ||
""" | ||
E = 20 | ||
S = 80 | ||
T = int(round(4.0 * S)) | ||
start_year = 2018 | ||
|
||
(omega, g_n_ss, omega_SS, surv_rate, rho, g_n_vector, imm_rates, | ||
omega_S_preTP) = demographics.get_pop_objs(E, S, T, 1, 100, | ||
start_year, False) | ||
|
||
assert (np.any(np.absolute(imm_rates[:-1, :] - imm_rates[1:, :]) < | ||
0.0001)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters