Skip to content

Commit 275c500

Browse files
authored
Remove inferred is_parent formula (#1595)
1 parent d47be81 commit 275c500

4 files changed

Lines changed: 37 additions & 23 deletions

File tree

changelog.d/1031.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Removed the inferred `is_parent` formula so datasets provide parent status directly.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
- name: is_parent is not inferred from family composition
2+
period: 2024
3+
input:
4+
people:
5+
adult:
6+
age: 35
7+
child:
8+
age: 5
9+
benunits:
10+
benunit:
11+
members: [adult, child]
12+
households:
13+
household:
14+
members: [adult, child]
15+
output:
16+
is_parent: [false, false]
17+
18+
- name: is_parent can be provided as an input
19+
period: 2024
20+
input:
21+
people:
22+
adult:
23+
age: 35
24+
is_parent: true
25+
child:
26+
age: 5
27+
benunits:
28+
benunit:
29+
members: [adult, child]
30+
households:
31+
household:
32+
members: [adult, child]
33+
output:
34+
is_parent: [true, false]

policyengine_uk/variables/household/demographic/is_parent.py

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,4 @@ class is_parent(Variable):
66
entity = Person
77
label = "Whether this person is a parent in their benefit unit"
88
definition_period = YEAR
9-
10-
def formula(person, period, parameters):
11-
benunit = person.benunit
12-
age = person("age", period)
13-
family_type = benunit("family_type", period)
14-
15-
# Find two oldest members
16-
benunit_ages = benunit.members("age", period)
17-
adult_index = person("adult_index", period)
18-
19-
# Get family types enum
20-
family_types = family_type.possible_values
21-
22-
# For lone parents (FamilyType.LONE_PARENT), only the eldest is parent
23-
is_lone_parent = (family_type == family_types.LONE_PARENT) & (adult_index == 1)
24-
25-
# For couples with children (FamilyType.COUPLE_WITH_CHILDREN), two eldest are parents
26-
is_couple_parent = (family_type == family_types.COUPLE_WITH_CHILDREN) & (
27-
(adult_index == 1) | (adult_index == 2)
28-
)
29-
30-
return is_lone_parent | is_couple_parent
9+
default_value = False

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)