Skip to content

Commit 00ee7d2

Browse files
committed
aca/model.create_model: register target_his at base layer
Same fix as baseline.model.create_model e1a3eb2: ACA variant model creation also takes its own path through `Model(...)`, so the production `task_simulate_aca_*` flows hit the same "Unrecognised indexing parameter 'target_his'" error after the pension correction landed. Move the derived-categorical declaration into the function itself rather than relying on per-caller setup. Tighten the param annotation to match pylcm's flat `Mapping[str, DiscreteGrid]`.
1 parent e1a3eb2 commit 00ee7d2

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/aca_model/aca/model.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from aca_model.aca import PolicyVariant
1313
from aca_model.aca.regimes import build_all_regimes
14+
from aca_model.baseline.health_insurance import HealthInsuranceState
1415
from aca_model.baseline.regimes import RegimeId
1516
from aca_model.baseline.regimes._common import MAX_CONSUMPTION
1617
from aca_model.config import GRID_CONFIG, MODEL_CONFIG, GridConfig
@@ -22,8 +23,7 @@ def create_model(
2223
policy: PolicyVariant = PolicyVariant.ACA,
2324
fixed_params: Mapping[str, Any] | None = None,
2425
wage_params: Mapping[str, Any] | None = None,
25-
derived_categoricals: Mapping[str, DiscreteGrid | Mapping[str, DiscreteGrid]]
26-
| None = None,
26+
derived_categoricals: Mapping[str, DiscreteGrid] | None = None,
2727
grid_config: GridConfig = GRID_CONFIG,
2828
) -> Model:
2929
"""Create an ACA policy variant model.
@@ -61,13 +61,21 @@ def create_model(
6161
wage_params=wage_params,
6262
)
6363

64+
# See `baseline.model.create_model` for why `target_his` is declared
65+
# as a base-layer derived categorical.
66+
base_derived: dict[str, DiscreteGrid] = {
67+
"target_his": DiscreteGrid(HealthInsuranceState),
68+
}
69+
if derived_categoricals is not None:
70+
base_derived.update(derived_categoricals)
71+
6472
model = Model(
6573
regimes=regimes,
6674
ages=ages,
6775
regime_id_class=RegimeId,
6876
description=f"Structural retirement model ({policy.name})",
6977
fixed_params=fixed_params or {},
70-
derived_categoricals=derived_categoricals,
78+
derived_categoricals=base_derived,
7179
n_subjects=n_subjects,
7280
)
7381
model.max_consumption = MAX_CONSUMPTION

0 commit comments

Comments
 (0)