Skip to content

fix: ensure enum columns decode to strings for non-URL dataset paths#1504

Merged
nwoodruff-co merged 4 commits intomainfrom
fix/enum-decoding-non-url-datasets
Feb 23, 2026
Merged

fix: ensure enum columns decode to strings for non-URL dataset paths#1504
nwoodruff-co merged 4 commits intomainfrom
fix/enum-decoding-non-url-datasets

Conversation

@nwoodruff-co
Copy link
Contributor

Summary

  • _pre_encode_enum_columns was only called in build_from_url, so _enum_columns was never populated when a UKSingleYearDataset or UKMultiYearDataset was passed directly to Microsimulation()
  • As a result, .person/.benunit/.household property getters returned raw int16 values instead of string enum labels (e.g. 0 instead of 'FT_EMPLOYED')
  • Fixes sim.dataset.data.person showing integers in policyengine.py context

Changes

  • Call _pre_encode_enum_columns in build_from_single_year_dataset after extend_single_year_dataset
  • Guard build_from_multi_year_dataset to call _pre_encode_enum_columns if _enum_columns is not already populated (avoids redundant re-encoding from the URL cache path)

Test plan

  • sim.dataset[year].person['current_education'] returns string labels not integers when Microsimulation is initialised with a UKSingleYearDataset
  • Existing tests pass

_pre_encode_enum_columns was only called in build_from_url, so
_enum_columns was never populated when a UKSingleYearDataset or
UKMultiYearDataset was passed directly. The .person/.benunit/.household
properties then returned raw int16 values instead of string enum labels.

Now calls _pre_encode_enum_columns in build_from_single_year_dataset and
guards build_from_multi_year_dataset to encode if not already done.
@nwoodruff-co nwoodruff-co marked this pull request as ready for review February 23, 2026 12:47
@nwoodruff-co nwoodruff-co merged commit 4439b76 into main Feb 23, 2026
2 checks passed
@nwoodruff-co nwoodruff-co deleted the fix/enum-decoding-non-url-datasets branch February 23, 2026 13:06
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