Skip to content
30 changes: 13 additions & 17 deletions src/_gettsim/arbeitslosengeld_2/group_by_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,53 @@

import numpy

from ttsim import AggregateByGroupSpec, group_by_function
from ttsim import AggregateByGroupSpec, AggregationType, group_by_function

# TODO(@MImmesberger): Many of these keys can go once we have `_eg` for SGB XII.
# https://github.com/iza-institute-of-labor-economics/gettsim/issues/738
aggregation_specs = {
"anzahl_erwachsene_fg": AggregateByGroupSpec(
source="familie__erwachsen",
aggr="sum",
aggr=AggregationType.SUM,
),
"anzahl_kinder_fg": AggregateByGroupSpec(
source="familie__kind",
aggr="sum",
aggr=AggregationType.SUM,
),
"anzahl_kinder_bis_6_fg": AggregateByGroupSpec(
source="familie__kind_bis_6",
aggr="sum",
aggr=AggregationType.SUM,
),
"anzahl_kinder_bis_15_fg": AggregateByGroupSpec(
source="familie__kind_bis_15",
aggr="sum",
aggr=AggregationType.SUM,
),
"anzahl_erwachsene_bg": AggregateByGroupSpec(
source="familie__erwachsen",
aggr="sum",
aggr=AggregationType.SUM,
),
"anzahl_kinder_bg": AggregateByGroupSpec(
source="familie__kind",
aggr="sum",
),
"anzahl_personen_bg": AggregateByGroupSpec(
aggr="count",
aggr=AggregationType.SUM,
),
"anzahl_personen_bg": AggregateByGroupSpec(aggr=AggregationType.COUNT),
"anzahl_kinder_bis_17_bg": AggregateByGroupSpec(
source="familie__kind_bis_17",
aggr="sum",
aggr=AggregationType.SUM,
),
"alleinerziehend_bg": AggregateByGroupSpec(
source="familie__alleinerziehend",
aggr="any",
aggr=AggregationType.ANY,
),
"anzahl_erwachsene_eg": AggregateByGroupSpec(
source="familie__erwachsen",
aggr="sum",
aggr=AggregationType.SUM,
),
"anzahl_kinder_eg": AggregateByGroupSpec(
source="familie__kind",
aggr="sum",
),
"anzahl_personen_eg": AggregateByGroupSpec(
aggr="count",
aggr=AggregationType.SUM,
),
"anzahl_personen_eg": AggregateByGroupSpec(aggr=AggregationType.COUNT),
}


Expand Down
4 changes: 2 additions & 2 deletions src/_gettsim/arbeitslosengeld_2/kindergeldübertrag.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import numpy

from ttsim import AggregateByPIDSpec, join_numpy, policy_function
from ttsim import AggregateByPIDSpec, AggregationType, join_numpy, policy_function

aggregation_specs = {
"kindergeldübertrag_m": AggregateByPIDSpec(
p_id_to_aggregate_by="kindergeld__p_id_empfänger",
source="differenz_kindergeld_kindbedarf_m",
aggr="sum",
aggr=AggregationType.SUM,
),
}

Expand Down
4 changes: 2 additions & 2 deletions src/_gettsim/einkommensteuer/abzüge/sonderausgaben.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Tax allowances for special expenses."""

from ttsim import AggregateByPIDSpec, policy_function
from ttsim import AggregateByPIDSpec, AggregationType, policy_function

aggregation_specs = {
"betreuungskosten_elternteil_m": AggregateByPIDSpec(
p_id_to_aggregate_by="p_id_betreuungskosten_träger",
source="betreuungskosten_m",
aggr="sum",
aggr=AggregationType.SUM,
),
}

Expand Down
11 changes: 8 additions & 3 deletions src/_gettsim/einkommensteuer/einkommensteuer.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
"""Income taxes."""

from ttsim import AggregateByPIDSpec, piecewise_polynomial, policy_function
from ttsim import (
AggregateByPIDSpec,
AggregationType,
piecewise_polynomial,
policy_function,
)

aggregation_specs = {
"anzahl_kindergeld_ansprüche_1": AggregateByPIDSpec(
p_id_to_aggregate_by="familie__p_id_elternteil_1",
source="kindergeld__grundsätzlich_anspruchsberechtigt",
aggr="sum",
aggr=AggregationType.SUM,
),
"anzahl_kindergeld_ansprüche_2": AggregateByPIDSpec(
p_id_to_aggregate_by="familie__p_id_elternteil_2",
source="kindergeld__grundsätzlich_anspruchsberechtigt",
aggr="sum",
aggr=AggregationType.SUM,
),
}

Expand Down
8 changes: 3 additions & 5 deletions src/_gettsim/einkommensteuer/group_by_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

import numpy

from ttsim import AggregateByGroupSpec, group_by_function
from ttsim import AggregateByGroupSpec, AggregationType, group_by_function

aggregation_specs = {
"anzahl_personen_sn": AggregateByGroupSpec(
aggr="count",
),
"anzahl_personen_sn": AggregateByGroupSpec(aggr=AggregationType.COUNT),
"alleinerziehend_sn": AggregateByGroupSpec(
source="familie__alleinerziehend",
aggr="any",
aggr=AggregationType.ANY,
),
}

Expand Down
6 changes: 3 additions & 3 deletions src/_gettsim/einkommensteuer/kinderfreibetrag.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
"""Tax allowances for individuals or couples with children."""

from ttsim import AggregateByPIDSpec, policy_function
from ttsim import AggregateByPIDSpec, AggregationType, policy_function

aggregation_specs = {
"anzahl_kinderfreibeträge_1": AggregateByPIDSpec(
p_id_to_aggregate_by="p_id_kinderfreibetragsempfänger_1",
source="kindergeld__grundsätzlich_anspruchsberechtigt",
aggr="sum",
aggr=AggregationType.SUM,
),
"anzahl_kinderfreibeträge_2": AggregateByPIDSpec(
p_id_to_aggregate_by="p_id_kinderfreibetragsempfänger_2",
source="kindergeld__grundsätzlich_anspruchsberechtigt",
aggr="sum",
aggr=AggregationType.SUM,
),
}

Expand Down
21 changes: 13 additions & 8 deletions src/_gettsim/elterngeld/elterngeld.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,41 @@
"""Parental leave benefits."""

from ttsim import AggregateByGroupSpec, AggregateByPIDSpec, policy_function
from ttsim import (
AggregateByGroupSpec,
AggregateByPIDSpec,
AggregationType,
policy_function,
)

aggregation_specs = {
"kind_grundsätzlich_anspruchsberechtigt_fg": AggregateByGroupSpec(
source="kind_grundsätzlich_anspruchsberechtigt",
aggr="any",
aggr=AggregationType.ANY,
),
"anzahl_anträge_fg": AggregateByGroupSpec(
source="claimed",
aggr="sum",
aggr=AggregationType.SUM,
),
"bezugsmonate_partner": AggregateByPIDSpec(
p_id_to_aggregate_by="arbeitslosengeld_2__p_id_einstandspartner",
source="bisherige_bezugsmonate",
aggr="sum",
aggr=AggregationType.SUM,
),
"alter_monate_jüngstes_mitglied_fg": AggregateByGroupSpec(
source="alter_monate",
aggr="min",
aggr=AggregationType.MIN,
),
"anzahl_kinder_bis_2_fg": AggregateByGroupSpec(
source="familie__kind_bis_2",
aggr="sum",
aggr=AggregationType.SUM,
),
"anzahl_kinder_bis_5_fg": AggregateByGroupSpec(
source="familie__kind_bis_5",
aggr="sum",
aggr=AggregationType.SUM,
),
"anzahl_mehrlinge_jüngstes_kind_fg": AggregateByGroupSpec(
source="jüngstes_kind_oder_mehrling",
aggr="sum",
aggr=AggregationType.SUM,
),
}

Expand Down
4 changes: 2 additions & 2 deletions src/_gettsim/erziehungsgeld/erziehungsgeld.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Functions to compute parental leave benefits (Erziehungsgeld, -2007)."""

from ttsim import AggregateByPIDSpec, policy_function
from ttsim import AggregateByPIDSpec, AggregationType, policy_function

aggregation_specs = {
"anspruchshöhe_m": AggregateByPIDSpec(
p_id_to_aggregate_by="p_id_empfänger",
source="anspruchshöhe_kind_m",
aggr="sum",
aggr=AggregationType.SUM,
),
}

Expand Down
11 changes: 7 additions & 4 deletions src/_gettsim/familie/familie.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@

import numpy

from ttsim import AggregateByGroupSpec, group_by_function, policy_function
from ttsim import (
AggregateByGroupSpec,
AggregationType,
group_by_function,
policy_function,
)

aggregation_specs = {
"anzahl_personen_ehe": AggregateByGroupSpec(
aggr="count",
),
"anzahl_personen_ehe": AggregateByGroupSpec(aggr=AggregationType.COUNT),
}


Expand Down
10 changes: 4 additions & 6 deletions src/_gettsim/household_characteristics.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
from ttsim import AggregateByGroupSpec, policy_function
from ttsim import AggregateByGroupSpec, AggregationType, policy_function

aggregation_specs = {
"anzahl_erwachsene_hh": AggregateByGroupSpec(
source="familie__erwachsen",
aggr="sum",
aggr=AggregationType.SUM,
),
"anzahl_rentenbezieher_hh": AggregateByGroupSpec(
source="sozialversicherung__rente__bezieht_rente",
aggr="sum",
),
"anzahl_personen_hh": AggregateByGroupSpec(
aggr="count",
aggr=AggregationType.SUM,
),
"anzahl_personen_hh": AggregateByGroupSpec(aggr=AggregationType.COUNT),
}


Expand Down
4 changes: 2 additions & 2 deletions src/_gettsim/kindergeld/kindergeld.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import numpy

from ttsim import AggregateByPIDSpec, join_numpy, policy_function
from ttsim import AggregateByPIDSpec, AggregationType, join_numpy, policy_function

aggregation_specs = {
"anzahl_ansprüche": AggregateByPIDSpec(
p_id_to_aggregate_by="p_id_empfänger",
source="grundsätzlich_anspruchsberechtigt",
aggr="sum",
aggr=AggregationType.SUM,
),
}

Expand Down
4 changes: 2 additions & 2 deletions src/_gettsim/kinderzuschlag/einkommen.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Income relevant for calculation of Kinderzuschlag."""

from ttsim import AggregateByGroupSpec, policy_function
from ttsim import AggregateByGroupSpec, AggregationType, policy_function

aggregation_specs = {
"arbeitslosengeld_2__anzahl_kinder_bg": AggregateByGroupSpec(
source="kindergeld__anzahl_ansprüche",
aggr="sum",
aggr=AggregationType.SUM,
),
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
"""Contribution rate to public long-term care insurance."""

from ttsim import AggregateByPIDSpec, policy_function
from ttsim import AggregateByPIDSpec, AggregationType, policy_function

aggregation_specs = {
"anzahl_kinder_bis_24_elternteil_1": AggregateByPIDSpec(
p_id_to_aggregate_by=("einkommensteuer__p_id_kinderfreibetragsempfänger_1"),
source="alter_bis_24",
aggr="sum",
aggr=AggregationType.SUM,
),
"anzahl_kinder_bis_24_elternteil_2": AggregateByPIDSpec(
p_id_to_aggregate_by=("einkommensteuer__p_id_kinderfreibetragsempfänger_2"),
source="alter_bis_24",
aggr="sum",
aggr=AggregationType.SUM,
),
}

Expand Down
4 changes: 2 additions & 2 deletions src/_gettsim/unterhaltsvorschuss/unterhaltsvorschuss.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import numpy

from ttsim import AggregateByPIDSpec, join_numpy, policy_function
from ttsim import AggregateByPIDSpec, AggregationType, join_numpy, policy_function

aggregation_specs = {
"an_elternteil_auszuzahlender_betrag_m": AggregateByPIDSpec(
p_id_to_aggregate_by="kindergeld__p_id_empfänger",
source="betrag_m",
aggr="sum",
aggr=AggregationType.SUM,
),
}

Expand Down
6 changes: 3 additions & 3 deletions src/_gettsim/vorrangprüfungen/vorrangprüfungen.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""Priority checks of transfers against each other."""

from ttsim import AggregateByGroupSpec, policy_function
from ttsim import AggregateByGroupSpec, AggregationType, policy_function

aggregation_specs = {
"wohngeld_vorrang_wthh": AggregateByGroupSpec(
source="wohngeld_vorrang_vor_arbeitslosengeld_2_bg",
aggr="any",
aggr=AggregationType.ANY,
),
"wohngeld_kinderzuschlag_vorrang_wthh": AggregateByGroupSpec(
source="wohngeld_und_kinderzuschlag_vorrang_vor_arbeitslosengeld_2_bg",
aggr="any",
aggr=AggregationType.ANY,
),
}

Expand Down
9 changes: 7 additions & 2 deletions src/_gettsim/wohngeld/einkommen.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
"""Income relevant for housing benefit calculation."""

from ttsim import AggregateByPIDSpec, piecewise_polynomial, policy_function
from ttsim import (
AggregateByPIDSpec,
AggregationType,
piecewise_polynomial,
policy_function,
)
from ttsim.config import numpy_or_jax as np

aggregation_specs = {
"alleinerziehendenbonus": AggregateByPIDSpec(
p_id_to_aggregate_by="kindergeld__p_id_empfänger",
source="kindergeld__kind_bis_10_mit_kindergeld",
aggr="sum",
aggr=AggregationType.SUM,
),
}

Expand Down
6 changes: 2 additions & 4 deletions src/_gettsim/wohngeld/group_by_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

import numpy

from ttsim import AggregateByGroupSpec, group_by_function
from ttsim import AggregateByGroupSpec, AggregationType, group_by_function

aggregation_specs = {
"anzahl_personen_wthh": AggregateByGroupSpec(
aggr="count",
),
"anzahl_personen_wthh": AggregateByGroupSpec(aggr=AggregationType.COUNT),
}


Expand Down
Loading