Skip to content

_normalise_period_key drops the stop date of start.stop reform keys #724

Open

Description

@MaxGhenis

_normalise_period_key (projects/policyengine-simulation-executor/src/policyengine_simulation_executor/simulation_runtime.py) reduces a start.stop period key to its start date:

def _normalise_period_key(period_key: Any) -> str:
    """Convert legacy ``start.stop`` period keys to v4 effective dates."""
    text = str(period_key)
    parts = text.split(".")
    if len(parts) > 1 and len(parts[0]) == 10:
        return parts[0]
    return text

_normalise_policy applies it to both the baseline and the reform policy before they reach policyengine.core.Simulation(policy=...). In policyengine.py main:

  • compile_reform_to_policy turns each {path: {date: value}} entry into a ParameterValue with end_date=None (tax_benefit_models/common/reform.py);
  • reform_dict_from_parameter_values (utils/parametric_reforms.py) runs such an open-ended value until the day before the next value of the same parameter starts, or to 2100-12-31.

So the stop date of a bounded app value never reaches the simulation. For example, {"2026-01-01.2026-12-31": 0.05} stays in force after 2026, until the next start date the policy gives that parameter, or to 2100. In a budget window, later years then use the reform value instead of the baseline.

This comes from reading sim-api main and policyengine.py main on 2026-10-06; I have not run it. The release bundle sim-api pins may resolve an older policyengine.py. Found while reviewing PolicyEngine/policyengine-us#9628.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions