Skip to content

Commit

Permalink
Bug fixes (#989)
Browse files Browse the repository at this point in the history
* Fix Hard-code secondary threshold freeze to 2027 #987

* Fix hosuehold app bugs

* Unit

* Fix unit
  • Loading branch information
nikhilwoodruff authored Oct 28, 2024
1 parent b5667a0 commit 3f83559
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 5 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).

## [2.14.0] - 2024-10-28 12:09:01

### Fixed

- Bugs affecting household app calculations.

## [2.13.2] - 2024-10-28 10:46:29

### Fixed
Expand Down Expand Up @@ -1573,6 +1579,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0



[2.14.0]: https://github.com/PolicyEngine/openfisca-uk/compare/2.13.2...2.14.0
[2.13.2]: https://github.com/PolicyEngine/openfisca-uk/compare/2.13.1...2.13.2
[2.13.1]: https://github.com/PolicyEngine/openfisca-uk/compare/2.13.0...2.13.1
[2.13.0]: https://github.com/PolicyEngine/openfisca-uk/compare/2.12.0...2.13.0
Expand Down
5 changes: 5 additions & 0 deletions changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1320,3 +1320,8 @@
fixed:
- Threshold freeze for ST extended to 2027.
date: 2024-10-28 10:46:29
- bump: minor
changes:
fixed:
- Bugs affecting household app calculations.
date: 2024-10-28 12:09:01
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: National Insurance contribution rate by employers on earnings above
metadata:
label: NI Employer rate
propagate_metadata_to_children: true
unit: /1
reference: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/882271/Table-a4.pdf
unit: marginal-rate
values:
2015-06-01: 0.138
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class attends_private_school(Variable):
value_type = bool

def formula(person, period, parameters):
if not hasattr(person.simulation, "dataset"):
return 0
household = person.household
# To ensure that our model matches
# total number of students actually enrolled
Expand Down Expand Up @@ -37,6 +39,9 @@ def formula(person, period, parameters):
household_weight = household("household_weight", period)
weighted_income = MicroSeries(net_income, weights=household_weight)

if household_weight.sum() < 1e6:
return 0

percentile = np.zeros_like(weighted_income).astype(numpy.int64)
mask = household_weight > 0

Expand All @@ -60,7 +65,9 @@ def formula(person, period, parameters):
* is_child
)

return random(person) < p_attends_private_school
value = random(person) < p_attends_private_school

return value


class private_school_vat(Variable):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,15 @@ def formula(person, period, parameters):
total_consumption = (consumption * person_weight).sum()
share_of_total_consumption = consumption / total_consumption

return (
value = (
amount_paid_by_employers
* share_of_total_consumption
* consumer_incidence
)

if total_consumption == 0:
return 0


class employer_ni_response_capital_incidence(Variable):
label = "capital response to employer NI reform"
Expand Down Expand Up @@ -199,12 +202,15 @@ def formula(person, period, parameters):
total_wealth = (wealth * person_weight).sum()
share_of_total_wealth = wealth / total_wealth

return (
value = (
amount_paid_by_employers
* share_of_total_wealth
* capital_incidence
)

if total_wealth == 0:
return 0


class employer_ni_fixed_employer_cost_change(Variable):
label = "employer NI reform incidence"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name="PolicyEngine-UK",
version="2.13.2",
version="2.14.0",
author="PolicyEngine",
author_email="[email protected]",
classifiers=[
Expand Down

0 comments on commit 3f83559

Please sign in to comment.