Skip to content
Open
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
3 changes: 3 additions & 0 deletions .github/workflows/pr_code_changes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ jobs:
- name: Test specific core import
run: python -c "from policyengine_core.data import Dataset; print('Core import OK')"

- name: Test Microsimulation with direct dependencies only
run: python -m pytest policyengine_us_data/tests/test_datasets/test_data_us_pipeline.py -v

Test:
runs-on: ubuntu-latest
needs: Lint
Expand Down
4 changes: 4 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- bump: minor
changes:
changed:
- Added test to ensure microsimulation runs with only us-data direct dependencies.
8 changes: 2 additions & 6 deletions policyengine_us_data/datasets/cps/enhanced_cps.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@
from pathlib import Path


try:
import torch
except ImportError:
torch = None


def reweight(
original_weights,
loss_matrix,
Expand All @@ -38,6 +32,8 @@ def reweight(
init_mean=0.999, # initial proportion with non-zero weights, set near 0
temperature=0.5, # Usual values .5 to 3, .5 was working better
):
import torch

target_names = np.array(loss_matrix.columns)
is_national = loss_matrix.columns.str.startswith("nation/")
loss_matrix = torch.tensor(loss_matrix.values, dtype=torch.float32)
Expand Down
11 changes: 11 additions & 0 deletions policyengine_us_data/tests/test_datasets/test_data_us_pipeline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
Tests to ensure Microsimulations can run with the us-data direct dependencies only.
"""


def test_microsimulation_runs():
from policyengine_us import Microsimulation
from policyengine_us_data.datasets.cps import EnhancedCPS_2024

sim = Microsimulation(dataset=EnhancedCPS_2024)
sim.calculate("employment_income", map_to="household", period=2025)
Loading