|
| 1 | +"""Country configuration strategy — holds all country-specific parameters.""" |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +from dataclasses import dataclass, field |
| 6 | + |
| 7 | + |
| 8 | +@dataclass(frozen=True) |
| 9 | +class CountryConfig: |
| 10 | + """All country-specific parameters needed by compute functions. |
| 11 | +
|
| 12 | + Individual compute functions read the fields they need from this |
| 13 | + config rather than accepting a ``country_id`` string and branching. |
| 14 | + """ |
| 15 | + |
| 16 | + country_id: str |
| 17 | + income_variable: str |
| 18 | + programs: dict[str, dict] = field(default_factory=dict) |
| 19 | + budget_variables: dict[str, str] = field(default_factory=dict) |
| 20 | + poverty_variables: dict[str, str] = field(default_factory=dict) |
| 21 | + poverty_entity: str = "person" |
| 22 | + poverty_breakdowns: tuple[str, ...] = () |
| 23 | + inequality_income_variable: str | None = None |
| 24 | + inequality_entity: str = "household" |
| 25 | + |
| 26 | + |
| 27 | +US_CONFIG = CountryConfig( |
| 28 | + country_id="us", |
| 29 | + income_variable="household_net_income", |
| 30 | + programs={ |
| 31 | + "income_tax": {"entity": "tax_unit", "is_tax": True}, |
| 32 | + "employee_payroll_tax": {"entity": "person", "is_tax": True}, |
| 33 | + "snap": {"entity": "spm_unit", "is_tax": False}, |
| 34 | + "tanf": {"entity": "spm_unit", "is_tax": False}, |
| 35 | + "ssi": {"entity": "spm_unit", "is_tax": False}, |
| 36 | + "social_security": {"entity": "person", "is_tax": False}, |
| 37 | + }, |
| 38 | + budget_variables={ |
| 39 | + "household_tax": "household", |
| 40 | + "household_benefits": "household", |
| 41 | + "household_net_income": "household", |
| 42 | + "household_state_income_tax": "tax_unit", |
| 43 | + }, |
| 44 | + poverty_variables={ |
| 45 | + "spm": "spm_unit_is_in_spm_poverty", |
| 46 | + "spm_deep": "spm_unit_is_in_deep_spm_poverty", |
| 47 | + }, |
| 48 | + poverty_entity="person", |
| 49 | + poverty_breakdowns=("age", "gender", "race"), |
| 50 | + inequality_income_variable="household_net_income", |
| 51 | + inequality_entity="household", |
| 52 | +) |
| 53 | + |
| 54 | +UK_CONFIG = CountryConfig( |
| 55 | + country_id="uk", |
| 56 | + income_variable="equiv_hbai_household_net_income", |
| 57 | + programs={ |
| 58 | + "income_tax": {"entity": "person", "is_tax": True}, |
| 59 | + "national_insurance": {"entity": "person", "is_tax": True}, |
| 60 | + "vat": {"entity": "household", "is_tax": True}, |
| 61 | + "council_tax": {"entity": "household", "is_tax": True}, |
| 62 | + "universal_credit": {"entity": "person", "is_tax": False}, |
| 63 | + "child_benefit": {"entity": "person", "is_tax": False}, |
| 64 | + "pension_credit": {"entity": "person", "is_tax": False}, |
| 65 | + "income_support": {"entity": "person", "is_tax": False}, |
| 66 | + "working_tax_credit": {"entity": "person", "is_tax": False}, |
| 67 | + "child_tax_credit": {"entity": "person", "is_tax": False}, |
| 68 | + }, |
| 69 | + budget_variables={ |
| 70 | + "household_tax": "household", |
| 71 | + "household_benefits": "household", |
| 72 | + "household_net_income": "household", |
| 73 | + }, |
| 74 | + poverty_variables={ |
| 75 | + "absolute_bhc": "in_poverty_bhc", |
| 76 | + "absolute_ahc": "in_poverty_ahc", |
| 77 | + "relative_bhc": "in_relative_poverty_bhc", |
| 78 | + "relative_ahc": "in_relative_poverty_ahc", |
| 79 | + }, |
| 80 | + poverty_entity="person", |
| 81 | + poverty_breakdowns=("age", "gender"), |
| 82 | + inequality_income_variable="equiv_hbai_household_net_income", |
| 83 | + inequality_entity="household", |
| 84 | +) |
0 commit comments