Skip to content
This repository was archived by the owner on Jul 6, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/__tests__/data/reformDefinitionCode.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
getImplementationCode,
sanitizeStringToPython,
} from "data/reformDefinitionCode";
import { POPULACE_US_DEFAULT_DATASET_URI } from "data/countries";
import {
baselinePolicyUS,
baselinePolicyUK,
Expand Down Expand Up @@ -262,7 +263,7 @@ describe("Test getImplementationCode", () => {
expect(output).toBeInstanceOf(Array);
expect(output).toContain("baseline = Microsimulation(reform=baseline)");
});
test("If US state, return lines with pooled 3-year CPS dataset", () => {
test("If US state, return lines with the certified populace-us dataset", () => {
let testPolicy = JSON.parse(JSON.stringify(baselinePolicyUS));
testPolicy = {
...testPolicy,
Expand All @@ -286,10 +287,10 @@ describe("Test getImplementationCode", () => {
);
expect(output).toBeInstanceOf(Array);
expect(output).toContain(
'baseline = Microsimulation(dataset="hf://policyengine/policyengine-us-data/pooled_3_year_cps_2023.h5")',
`baseline = Microsimulation(dataset="${POPULACE_US_DEFAULT_DATASET_URI}")`,
);
expect(output).toContain(
'reformed = Microsimulation(reform=reform, dataset="hf://policyengine/policyengine-us-data/pooled_3_year_cps_2023.h5")',
`reformed = Microsimulation(reform=reform, dataset="${POPULACE_US_DEFAULT_DATASET_URI}")`,
);
});
test("If dataset provided, return lines with dataset", () => {
Expand All @@ -303,10 +304,10 @@ describe("Test getImplementationCode", () => {
);
expect(output).toBeInstanceOf(Array);
expect(output).toContain(
'baseline = Microsimulation(dataset="hf://policyengine/policyengine-us-data/enhanced_cps_2024.h5")',
`baseline = Microsimulation(dataset="${POPULACE_US_DEFAULT_DATASET_URI}")`,
);
});
test("If dataset provided alongside US state, return lines with dataset, not Pooled 3-Year CPS", () => {
test("If dataset provided alongside US state, return lines with dataset, not the state fallback", () => {
const output = getImplementationCode(
"policy",
"ks",
Expand All @@ -317,7 +318,7 @@ describe("Test getImplementationCode", () => {
);
expect(output).toBeInstanceOf(Array);
expect(output).toContain(
'baseline = Microsimulation(dataset="hf://policyengine/policyengine-us-data/enhanced_cps_2024.h5")',
`baseline = Microsimulation(dataset="${POPULACE_US_DEFAULT_DATASET_URI}")`,
);
});
});
Expand Down
11 changes: 10 additions & 1 deletion src/data/countries.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,21 @@ export const STATUS_TEXT_COLORS = {
Pending: colors.BLACK,
};

// The certified populace-us dataset that policyengine.py resolves as its
// default US microdata (see src/policyengine/data/bundle/manifest.json's
// data_releases.us.default_dataset_uri in PolicyEngine/policyengine.py).
// This pins the certified revision so "Reproduce in Python" snippets stay
// byte-reproducible; bump the revision suffix when populace-us is
// re-certified (see PolicyEngine/populace#204 for the migration history).
Comment on lines +56 to +61
export const POPULACE_US_DEFAULT_DATASET_URI =
"hf://policyengine/populace-us/populace_us_2024.h5@populace-us-2024-sparse-l0-refit-57k-71a0887-national-only-20260701";

// Map dataset keywords to their equivalents
// in the actual US package; at the moment,
// this only applies to the "enhanced_cps"
// dataset selection
export const DEFAULT_DATASETS = {
enhanced_cps: "hf://policyengine/policyengine-us-data/enhanced_cps_2024.h5",
enhanced_cps: POPULACE_US_DEFAULT_DATASET_URI,
};

const DEFAULT_US_HOUSEHOLD = {
Expand Down
8 changes: 5 additions & 3 deletions src/data/reformDefinitionCode.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { optimiseHousehold } from "../api/variables";
import { defaultYear } from "./constants";
import { DEFAULT_DATASETS } from "./countries";
import { DEFAULT_DATASETS, POPULACE_US_DEFAULT_DATASET_URI } from "./countries";
import { wrappedJsonStringify } from "./wrappedJson";

export function getReproducibilityCodeBlock(
Expand Down Expand Up @@ -184,8 +184,10 @@ export function getImplementationCode(
if (hasDatasetSpecified) {
datasetText = DEFAULT_DATASETS[dataset];
} else if (isState) {
datasetText =
"hf://policyengine/policyengine-us-data/pooled_3_year_cps_2023.h5";
// State-level runs use the same certified populace-us national dataset;
// state regions scope it by state_fips rather than shipping a separate
// state-level file (see PolicyEngine/populace#204).
datasetText = POPULACE_US_DEFAULT_DATASET_URI;
}

const datasetSpecifier = datasetText ? `dataset="${datasetText}"` : "";
Expand Down