Skip to content
Merged
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
32 changes: 27 additions & 5 deletions src/_gettsim/arbeitslosengeld_2/group_by_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def bg_id(


@group_by_function()
def fg_id( # noqa: PLR0913
def fg_id( # noqa: PLR0913 PLR0912
p_id_einstandspartner: numpy.ndarray[int],
p_id: numpy.ndarray[int],
hh_id: numpy.ndarray[int],
Expand Down Expand Up @@ -138,10 +138,6 @@ def fg_id( # noqa: PLR0913
current_p_id_einstandspartner = p_id_einstandspartner[index]
current_p_id_children = p_id_to_p_ids_children.get(current_p_id, [])

# Assign fg to einstandspartner
if current_p_id_einstandspartner >= 0:
p_id_to_fg_id[current_p_id_einstandspartner] = next_fg_id

# Assign fg to children
for current_p_id_child in current_p_id_children:
child_index = p_id_to_index[current_p_id_child]
Expand All @@ -160,6 +156,32 @@ def fg_id( # noqa: PLR0913
):
p_id_to_fg_id[current_p_id_child] = next_fg_id

# Assign fg to einstandspartner
if current_p_id_einstandspartner >= 0:
p_id_to_fg_id[current_p_id_einstandspartner] = next_fg_id
current_p_id_einstandspartner_children = p_id_to_p_ids_children.get(
current_p_id_einstandspartner, []
)
# Assign fg to children of einstandspartner
for current_p_id_child in current_p_id_einstandspartner_children:
if current_p_id_child in p_id_to_fg_id:
continue
child_index = p_id_to_index[current_p_id_child]
child_hh_id = hh_id[child_index]
child_alter = alter[child_index]
child_p_id_children = p_id_to_p_ids_children.get(current_p_id_child, [])

if (
child_hh_id == current_hh_id
# TODO (@MImmesberger): Check correct conditions for grown up children
# https://github.com/iza-institute-of-labor-economics/gettsim/pull/509
# TODO(@MImmesberger): Remove hard-coded number
# https://github.com/iza-institute-of-labor-economics/gettsim/issues/668
and child_alter < 25
and len(child_p_id_children) == 0
):
p_id_to_fg_id[current_p_id_child] = next_fg_id

next_fg_id += 1

# Compute result vector
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
info:
note: ''
source: ''
inputs:
provided:
p_id:
- 0
- 1
- 2
- 3
- 4
- 5
alter:
- 12
- 39
- 13
- 12
- 22
- 42
hh_id:
- 0
- 0
- 0
- 0
- 0
- 0
p_id_einstandspartner:
- -1
- 5
- -1
- -1
- -1
- 1
familie__p_id_elternteil_1:
- 1
- -1
- 1
- 1
- 5
- -1
familie__p_id_elternteil_2:
- -1
- -1
- -1
- 5
- -1
- -1
eigenbedarf_gedeckt:
- false
- false
- false
- false
- false
- false
outputs:
arbeitslosengeld_2__fg_id:
- 1
- 1
- 1
- 1
- 1
- 1
arbeitslosengeld_2__bg_id:
- 100
- 100
- 100
- 100
- 100
- 100
arbeitslosengeld_2__eg_id:
- 0
- 1
- 2
- 3
- 4
- 1
Loading