Skip to content

Commit

Permalink
Merge pull request #18 from PolicyEngine/uk-package-compatibility
Browse files Browse the repository at this point in the history
Make compatible with policyengine-uk
  • Loading branch information
nikhilwoodruff authored Sep 17, 2024
2 parents bcdf16a + 3fc0938 commit 61435c1
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.2.0] - 2024-09-18 00:32:05

### Fixed

- Compatibility with PolicyEngine UK.

## [1.1.0] - 2024-09-17 18:05:27

### Changed
Expand All @@ -19,4 +25,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0



[1.2.0]: https://github.com/PolicyEngine/policyengine-us-data/compare/1.1.0...1.2.0
[1.1.0]: https://github.com/PolicyEngine/policyengine-us-data/compare/1.0.0...1.1.0
5 changes: 5 additions & 0 deletions changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@
changed:
- Lightened dependency list.
date: 2024-09-17 18:05:27
- bump: minor
changes:
fixed:
- Compatibility with PolicyEngine UK.
date: 2024-09-18 00:32:05
3 changes: 3 additions & 0 deletions policyengine_uk_data/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
FRS_2020_21,
FRS_2021_22,
FRS_2022_23,
ReweightedFRS_2022_23,
EnhancedFRS_2022_23,
SPI_2020_21,
]
2 changes: 1 addition & 1 deletion policyengine_uk_data/datasets/spi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from policyengine_core.data import Dataset
from policyengine_uk.data.storage import STORAGE_FOLDER
from policyengine_uk_data.storage import STORAGE_FOLDER
import pandas as pd
import numpy as np

Expand Down
7 changes: 4 additions & 3 deletions policyengine_uk_data/utils/imputations/capital_gains.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@

# Fit a spline to each income band's percentiles
from scipy.interpolate import UnivariateSpline
from policyengine_uk import Microsimulation
from tqdm import tqdm
from policyengine_uk_data.storage import STORAGE_FOLDER
from policyengine_uk.system import system
from tqdm import tqdm
import copy

import torch
Expand All @@ -24,6 +22,9 @@
def impute_capital_gains(dataset, time_period: int):
"""Assumes that the capital gains distribution is the same for all years."""

from policyengine_uk import Microsimulation
from policyengine_uk.system import system

sim = Microsimulation(dataset=dataset)
ti = sim.calculate("total_income", time_period)
household_weight = sim.calculate("household_weight", time_period).values
Expand Down
5 changes: 4 additions & 1 deletion policyengine_uk_data/utils/loss.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np
from policyengine_uk import Microsimulation
import pandas as pd
from policyengine_uk_data.storage import STORAGE_FOLDER
from policyengine_uk_data.utils import uprate_values
Expand Down Expand Up @@ -39,6 +38,8 @@ def create_target_matrix(

# First- tax-benefit outcomes from the DWP and OBR.

from policyengine_uk import Microsimulation

sim = Microsimulation(dataset=dataset, reform=reform)
sim.default_calculation_period = time_period

Expand Down Expand Up @@ -247,6 +248,8 @@ def pe_count(*variables):

def get_loss_results(dataset, time_period, reform=None):
matrix, targets = create_target_matrix(dataset, time_period, reform)
from policyengine_uk import Microsimulation

weights = (
Microsimulation(dataset=dataset, reform=reform)
.calculate("household_weight", time_period)
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "policyengine_uk_data"
version = "1.1.0"
version = "1.2.0"
description = "A package to create representative microdata for the UK."
readme = "README.md"
authors = [
Expand All @@ -31,6 +31,7 @@ dev = [
"furo",
"jupyter-book",
"yaml-changelog>=0.1.7",
"itables",
]

[tool.setuptools]
Expand Down

0 comments on commit 61435c1

Please sign in to comment.