- gadm03c.py: four cohorts with demography, cohort capability, mentoring, care load on attention; stationary at replacement fertility (tested) - life_cycle.py: L1 supported after fixing an inert mentoring term; L2 conditional on who carries care per person, care relief via participation claims protects carers' attention; L3 not supported (H lacks a durable component) - GADM-0.3.md complete; ASSEMBLY-WP-0006 (GADM-0.4, proposed residual) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Assistant: claude-code Assistant-Model: opus Assistant-Process: 1494246@bnt-lap001 Assistant-Session: caf6de6f-f9e4-47ce-a584-49baa271fa4b
44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
"""Sanity tests for GADM-0.3 with cohorts.
|
|
|
|
Usage: python3 -B -m unittest discover -s simulations/gadm02
|
|
"""
|
|
|
|
import unittest
|
|
|
|
import gadm03c as c
|
|
from scenarios import load_all
|
|
|
|
|
|
class TestCohorts(unittest.TestCase):
|
|
def test_bounded_and_shares_sum_to_one(self):
|
|
for name, sc in load_all().items():
|
|
for row in c.simulate(sc["params"], sc["init"]):
|
|
for k in c.STOCKS:
|
|
if not k.startswith("N"):
|
|
self.assertGreaterEqual(row[k], 0.0, (name, k))
|
|
self.assertLessEqual(row[k], 1.0, (name, k))
|
|
self.assertAlmostEqual(row["n_ch"] + row["n_w"] + row["n_s"] + row["n_d"], 1.0)
|
|
|
|
def test_replacement_fertility_is_stationary(self):
|
|
r = c.simulate()
|
|
for k in ("n_ch", "n_w", "n_s", "n_d"):
|
|
self.assertAlmostEqual(r[0][k], r[-1][k], places=3, msg=k)
|
|
|
|
def test_low_fertility_ages_the_population(self):
|
|
r = c.simulate({"birth": 0.75 / 45})[-1]
|
|
s = c.simulate()[-1]
|
|
self.assertGreater(r["n_s"] + r["n_d"], s["n_s"] + s["n_d"])
|
|
|
|
def test_mentoring_raises_capability(self):
|
|
lo = c.simulate({"tg": 0.0})[-1]["H"]
|
|
hi = c.simulate({"tg": 0.15})[-1]["H"]
|
|
self.assertGreater(hi, lo)
|
|
|
|
def test_care_relief_raises_working_age_attention(self):
|
|
lo = c.simulate({"cp": 0.0})[-1]["Aw"]
|
|
hi = c.simulate({"cp": 0.15})[-1]["Aw"]
|
|
self.assertGreater(hi, lo)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|