Skip to content

@categorical fields: int → ScalarInt (pylcm #350 cascade)#10

Open
hmgaudecker wants to merge 3 commits into
feature/runtime-consumption-pointsfrom
feature/categorical-scalarint
Open

@categorical fields: int → ScalarInt (pylcm #350 cascade)#10
hmgaudecker wants to merge 3 commits into
feature/runtime-consumption-pointsfrom
feature/categorical-scalarint

Conversation

@hmgaudecker
Copy link
Copy Markdown
Member

Summary

  • Mirrors the pylcm-side change in pylcm#350: every @categorical-decorated class moves its field annotations from int to ScalarInt, matching the runtime type the decorator now produces. Touches 13 classes across 6 files (PrefType, BenchmarkPrefType, LaborSupply, LaggedLaborSupply, SpousalIncome, IsMarried, HealthWithDisability, Health, GoodHealth, BuyPrivate, HealthInsuranceState, ClaimedSS, RegimeId).
  • Hashability fix: RegimeId.<name> is now a 0-d jnp.int32 scalar (unhashable), so the four id_to_name = {getattr(RegimeId, name): name ...} sites in baseline/regimes/_common.py coerce keys with int(...). precompute_target_regimes likewise wraps its getattr(RegimeId, ...) returns in int(...) so the precomputed mapping's values serve cleanly as dict keys and in-set members downstream.
  • CI temporarily pinned to pylcm @feat/categorical-scalarint; revert to @main once pylcm#350 merges.

Test plan

  • pixi run -e tests-cpu pytest aca-model -n 4 — 216 passed.
  • Workspace suite — 407 passed.
  • pixi run -e type-checking ty — clean.

🤖 Generated with Claude Code

hmgaudecker and others added 3 commits May 11, 2026 13:37
…alive

This batches several follow-ups from the consumption-floor refactor:

* Annotation sweep: every DAG function's scalar fixed_params move from
  Python `float`/`int`/`bool` to pylcm's post-#345 canonical scalar
  aliases (`ScalarFloat`, `ScalarInt`, `ScalarBool`, `Age`). Internal
  test helpers and analytics functions (`aime_to_pia`, `pia_to_aime`,
  `compute_hcc_insurer_table`) keep Python literal contracts.
* Tests: switch every callsite that passed Python literals to a 0-d
  jax scalar, matching the post-boundary contract.
* `u_alive` merges what were `u_canwork` / `u_forcedout`; leisure split
  three ways (`leisure_canwork_retiree_or_nongroup`,
  `leisure_canwork_tied`, `leisure_forcedout`).
* `u_dead` deleted; `preferences.bequest` registers as the dead-regime
  utility directly.
* `fixed_cost_of_work` extracted as a DAG function used by both
  `leisure_canwork_*` consumers.
* `reference_hours` raised to 1000.0 (lands on the working-hours grid).
* `_HCC_RHO` and `_WAGE_RHO` hoisted to module-level constants in
  `baseline/regimes/_common.py`.
* `consumption_dollars_grid`: Python-side guard rejects collapses where
  the married floor would sit at or beyond the third gridpoint.
* `MAX_CONSUMPTION_DOLLARS` carries a TODO pointing to pylcm#348 for
  routing through `fixed_params` once that lands.
* `benchmark_params.pkl` regenerated to reflect the
  `average_consumption_equiv` key + `reference_hours=1000.0`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mirrors the pylcm-side change: every `@categorical`-decorated class
moves its field annotations from `int` to `ScalarInt`, matching the
runtime type the decorator now produces. Touched 13 classes across
6 files (`PrefType`, `BenchmarkPrefType`, `LaborSupply`,
`LaggedLaborSupply`, `SpousalIncome`, `IsMarried`,
`HealthWithDisability`, `Health`, `GoodHealth`, `BuyPrivate`,
`HealthInsuranceState`, `ClaimedSS`, `RegimeId`).

Hashability fix: `RegimeId.<name>` is now a `jnp.int32` 0-d scalar
(unhashable), so the four `id_to_name = {getattr(RegimeId, name):
name ...}` sites in `baseline/regimes/_common.py` coerce keys with
`int(...)`. `precompute_target_regimes` likewise wraps its
`getattr(RegimeId, ...)` returns in `int(...)` so the precomputed
mapping's values can serve as dict keys and `in`-set members in
the per-target builders downstream.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Revert to @main once pylcm#350 lands so the cascade can be tested on
this branch in the meantime.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant