Skip to content

3.24.1: Microsimulation has no attribute _fast_cache when set_input is called #473

@MaxGhenis

Description

@MaxGhenis

Summary

3.24.1 resolves the ParameterScale.clear_parent_cache issue (thanks!) but immediately exposes a second regression in the same release: Microsimulation.set_input calls self._fast_cache.pop(...) but _fast_cache isn't initialised on the instance.

Stack trace

File "policyengine_uk/simulation.py", line 420, in build_from_single_year_dataset
    self.build_from_multi_year_dataset(dataset)
File "policyengine_uk/simulation.py", line 453, in build_from_multi_year_dataset
    self.set_input(variable, year, table[variable])
File "policyengine_core/simulations/simulation.py", line 1244, in set_input
    self._fast_cache.pop((variable_name, period), None)
AttributeError: 'Microsimulation' object has no attribute '_fast_cache'

Reproduction

Any path that goes Microsimulation(dataset=...).set_input(...) hits it. policyengine-uk-data's full data build reaches this as soon as it loads a UKSingleYearDataset into a Microsimulation.

Likely cause

Either:

  • Microsimulation.__init__ (or a parent init) needs to set self._fast_cache = {} unconditionally.
  • Or set_input needs to getattr(self, "_fast_cache", None) before .pop.

Blocks 3.24.x from being usable in downstream country packages.

Bonus: float-precision test regression in policyengine-uk

Separately, against 3.24.1 the UK's minimum_wage.yaml (scale parameter, absolute_error_margin: 0) now fails with 1e-7 precision wiggle:

minimum_wage@2021: [8.90999985] differs from 8.91 with an absolute margin [1.52587891e-07] > 0
minimum_wage@2025: [12.21000004] differs from 12.21 with an absolute margin [3.81469718e-08] > 0

Values look float32-rounded where they used to be float64-exact. Likely another artefact of the scale-parameter changes in 3.24.x. Same CI run: https://github.com/PolicyEngine/policyengine-uk/actions/runs/24578644004/job/71872370877

If you'd prefer these as separate issues I'll split them; filing together since they both surfaced in the same minute of PR CI output.

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