You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Simulation.subsample() raises TypeError: build_from_dataset() needs a dataset #2254
Run by the US + core hub on policyengine-uk 2.122.2, with policyengine-core at master 78a6c503 and at PolicyEngine/policyengine-core#573's head (same failure on both):
It has not been run on 2.125.1. The code below is unchanged on main, so the same failure is expected there.
Cause, read in the code
policyengine-core, policyengine_core/simulations/simulation.py (master 78a6c503): Simulation.subsample ends with self.build_from_dataset(), called with no arguments (line 3354). Core's own build_from_dataset(self) takes none (line 1080).
policyengine-uk, policyengine_uk/simulation.py (main e89b8abc): the override is build_from_dataset(self, dataset: Dataset) (line 455), which requires a positional dataset.
policyengine-uk defines no subsample of its own in simulation.py or microsimulation.py, so the inherited core method runs and hits the mismatch.
This predates core#573: it fails the same way on core master.
Options
Override subsample in policyengine-uk so that it works with the UK dataset classes, and add a test.
Override it to raise a clear NotImplementedError that points to the supported way to subsample UK data.
Make the override's dataset argument optional and fall back to self.dataset. Check first that core's subsample (which rebuilds self.dataset through Dataset.from_dataframe) produces something the UK builder can load; the signature may not be the only mismatch.
Whichever is chosen, a test that calls subsample() on a small UK simulation would catch a regression.
Not affected
Full-sample UK totals are identical under core master and core#573.
The fix is in policyengine-uk only (option 1, a UK subsample); nothing needs to change in policyengine-core. Making dataset optional (option 3) would have run and given wrong results: core's method reads memberships back from person_household_id and person_benunit_id, which the UK model stores as 32-bit floats, so identifiers above 2**24 would merge households. The PR description lists the other mismatches.
Activity
MaxGhenis commentedon Oct 10, 2026
Fix opened: #2265
The fix is in policyengine-uk only (option 1, a UK
subsample); nothing needs to change in policyengine-core. Makingdatasetoptional (option 3) would have run and given wrong results: core's method reads memberships back fromperson_household_idandperson_benunit_id, which the UK model stores as 32-bit floats, so identifiers above 2**24 would merge households. The PR description lists the other mismatches.