|
222 | 222 | "- `leaf_name`: The leaf name of the parameter in GETTSIM's policy environment.\n", |
223 | 223 | "- `start_date`: The date from which the parameter is valid (if applicable).\n", |
224 | 224 | "- `end_date`: The date until which the parameter is valid (if applicable).\n", |
225 | | - "- `unit`: The unit of the parameter (GEP 10). Parameters that map an input to an output\n", |
226 | | - " — the lookup tables and piecewise polynomials — leave this unset and declare\n", |
227 | | - " `input_unit` and `output_unit` instead.\n", |
| 225 | + "- `unit`: The unit of the parameter (GEP 10).\n", |
228 | 226 | "- `name`: The name of the parameter.\n", |
229 | 227 | "- `description`: A more elaborate description of the parameter.\n", |
230 | 228 | "- `value`: The value of the parameter.\n", |
231 | 229 | "- `note`: Some notes (if applicable).\n", |
232 | 230 | "- `reference`: A legal reference.\n", |
233 | 231 | "\n", |
234 | | - "When modifying parameters, you will mostly care about the `value` attribute. The unit is\n", |
235 | | - "required, so state the same one the parameter you replace declares.\n", |
| 232 | + "When modifying parameters, you will mostly care about the `value` attribute. Every\n", |
| 233 | + "parameter must declare a `unit` (GEP 10); keep the one the original declares.\n", |
| 234 | + "Parameters state a concrete currency, e.g. `TTSIMUnit.EUR.PER_YEAR`.\n", |
236 | 235 | "\n", |
237 | 236 | "### Scalar Parameters\n", |
238 | 237 | "\n", |
|
315 | 314 | "metadata": {}, |
316 | 315 | "outputs": [], |
317 | 316 | "source": [ |
318 | | - "from gettsim.tt import ScalarParam, Unit\n", |
| 317 | + "from gettsim.tt import ScalarParam, TTSIMUnit\n", |
319 | 318 | "\n", |
320 | | - "higher_arbeitnehmerpauschbetrag = ScalarParam(value=1600, unit=Unit.EUR.PER_YEAR)" |
| 319 | + "higher_arbeitnehmerpauschbetrag = ScalarParam(value=1600, unit=TTSIMUnit.EUR.PER_YEAR)" |
321 | 320 | ] |
322 | 321 | }, |
323 | 322 | { |
|
419 | 418 | "metadata": {}, |
420 | 419 | "outputs": [], |
421 | 420 | "source": [ |
422 | | - "from gettsim.tt import DictParam, Unit\n", |
| 421 | + "from gettsim.tt import DictParam, TTSIMUnit\n", |
423 | 422 | "\n", |
424 | 423 | "# Step 1: Create a copy of the status quo policy environment.\n", |
425 | 424 | "higher_kinderfreibetrag_pe = copy_environment(status_quo_environment)\n", |
|
430 | 429 | " \"betreuung_erziehung_ausbildung\": 1464,\n", |
431 | 430 | " \"sächliches_existenzminimum\": 4000,\n", |
432 | 431 | " },\n", |
433 | | - " unit=Unit.EUR.PER_YEAR,\n", |
| 432 | + " unit=TTSIMUnit.EUR.PER_YEAR,\n", |
434 | 433 | ")\n", |
435 | 434 | "\n", |
436 | 435 | "# Step 3: Insert the new parameter into the copied policy environment\n", |
|
557 | 556 | "source": [ |
558 | 557 | "from gettsim.tt import (\n", |
559 | 558 | " ConsecutiveIntLookupTableParam,\n", |
560 | | - " Unit,\n", |
| 559 | + " TTSIMUnit,\n", |
561 | 560 | " get_consecutive_int_lookup_table_param_value,\n", |
562 | 561 | ")\n", |
563 | 562 | "\n", |
|
581 | 580 | " },\n", |
582 | 581 | " xnp=np,\n", |
583 | 582 | " ),\n", |
584 | | - " input_unit=Unit.CALENDAR_YEAR,\n", |
585 | | - " output_unit=Unit.YEARS,\n", |
| 583 | + " input_unit=TTSIMUnit.CALENDAR_YEAR,\n", |
| 584 | + " output_unit=TTSIMUnit.YEARS,\n", |
586 | 585 | ")\n", |
587 | 586 | "\n", |
588 | 587 | "# Step 3: Insert the new parameter into the copied policy environment\n", |
|
687 | 686 | "metadata": {}, |
688 | 687 | "outputs": [], |
689 | 688 | "source": [ |
690 | | - "from gettsim.tt import PiecewisePolynomialParam, Unit, get_piecewise_parameters\n", |
| 689 | + "from gettsim.tt import PiecewisePolynomialParam, TTSIMUnit, get_piecewise_parameters\n", |
691 | 690 | "\n", |
692 | 691 | "increased_behindertenpauschbetrag = PiecewisePolynomialParam(\n", |
693 | 692 | " value=get_piecewise_parameters(\n", |
|
705 | 704 | " leaf_name=\"parameter_behindertenpauschbetrag\",\n", |
706 | 705 | " xnp=np,\n", |
707 | 706 | " ),\n", |
708 | | - " input_unit=Unit.DIMENSIONLESS,\n", |
709 | | - " output_unit=Unit.EUR.PER_YEAR,\n", |
| 707 | + " input_unit=TTSIMUnit.DIMENSIONLESS,\n", |
| 708 | + " output_unit=TTSIMUnit.EUR.PER_YEAR,\n", |
710 | 709 | ")\n", |
711 | 710 | "\n", |
712 | 711 | "increased_behindertenpauschbetrag_pe = copy_environment(status_quo_environment)\n", |
|
779 | 778 | "metadata": {}, |
780 | 779 | "outputs": [], |
781 | 780 | "source": [ |
782 | | - "from gettsim.tt import RawParam, Unit\n", |
| 781 | + "from gettsim.tt import RawParam, TTSIMUnit\n", |
783 | 782 | "\n", |
784 | 783 | "# Step 1: Create a copy of the status quo policy environment.\n", |
785 | 784 | "increased_tax_exemption_pe = copy_environment(status_quo_environment)\n", |
|
800 | 799 | " {\"interval\": \"[277825, inf)\", \"slope\": 0.45, \"quadratic\": 0},\n", |
801 | 800 | " ],\n", |
802 | 801 | " },\n", |
803 | | - " input_unit=Unit.EUR.PER_YEAR,\n", |
804 | | - " output_unit=Unit.EUR.PER_YEAR,\n", |
| 802 | + " input_unit=TTSIMUnit.EUR.PER_YEAR,\n", |
| 803 | + " output_unit=TTSIMUnit.EUR.PER_YEAR,\n", |
805 | 804 | ")\n", |
806 | 805 | "\n", |
807 | 806 | "# Step 3: Insert the new parameter into the copied policy environment\n", |
|
836 | 835 | "dictionary.\n", |
837 | 836 | "\n", |
838 | 837 | "```python\n", |
839 | | - "@param_function(unit=Unit.CURRENCY.PER_YEAR)\n", |
| 838 | + "@param_function(unit=TTSIMUnit.CURRENCY.PER_YEAR)\n", |
840 | 839 | "def kinderfreibetrag_pro_kind_y(parameter_kinderfreibetrag: dict[str, float]) -> float:\n", |
841 | 840 | " return sum(parameter_kinderfreibetrag.values())\n", |
842 | 841 | "```" |
|
868 | 867 | "The original function looks like this:\n", |
869 | 868 | "\n", |
870 | 869 | "```python\n", |
871 | | - "@param_function(unit=Unit.CURRENCY.PER_YEAR)\n", |
| 870 | + "@param_function(unit=TTSIMUnit.CURRENCY.PER_YEAR)\n", |
872 | 871 | "def kinderfreibetrag_pro_kind_y(\n", |
873 | 872 | " parameter_kinderfreibetrag: dict[str, float],\n", |
874 | 873 | ") -> float:\n", |
|
885 | 884 | "metadata": {}, |
886 | 885 | "outputs": [], |
887 | 886 | "source": [ |
888 | | - "from gettsim.tt import Unit, param_function\n", |
| 887 | + "from gettsim.tt import TTSIMUnit, param_function\n", |
889 | 888 | "\n", |
890 | 889 | "\n", |
891 | | - "@param_function(unit=Unit.CURRENCY.PER_YEAR)\n", |
| 890 | + "@param_function(unit=TTSIMUnit.CURRENCY.PER_YEAR)\n", |
892 | 891 | "def kinderfreibetrag_pro_kind_y(\n", |
893 | 892 | " parameter_kinderfreibetrag: dict[str, float],\n", |
894 | 893 | " kinderzuschlag__parameter_existenzminimum: dict[str, dict[str, float]],\n", |
|
966 | 965 | "`PolicyFunction`s are usually written to operate on rows of the input data. They can\n", |
967 | 966 | "take any parameter or other `ColumnObject` as inputs.\n", |
968 | 967 | "\n", |
| 968 | + "Like parameters, every `ColumnObject` declares a `unit` (GEP 10), so a function you\n", |
| 969 | + "add or replace must declare one too. Functions are typically currency-agnostic —\n", |
| 970 | + "they use `TTSIMUnit.CURRENCY.PER_YEAR`, not a concrete currency like `TTSIMUnit.EUR.PER_YEAR`.\n", |
| 971 | + "\n", |
969 | 972 | "**Note**: Some `PolicyFunction`s operate on columns of input data. Their decorator will\n", |
970 | 973 | "contain the term `vectorization_strategy=\"not_required\"`.\n", |
971 | 974 | "\n", |
|
975 | 978 | "This is the original function:\n", |
976 | 979 | "\n", |
977 | 980 | "```python\n", |
978 | | - "@policy_function(unit=Unit.CURRENCY.PER_YEAR)\n", |
| 981 | + "@policy_function(unit=TTSIMUnit.CURRENCY.PER_YEAR)\n", |
979 | 982 | "def kinderfreibetrag_y(\n", |
980 | 983 | " anzahl_kinderfreibeträge: int,\n", |
981 | 984 | " kinderfreibetrag_pro_kind_y: float,\n", |
|
1005 | 1008 | ")\n", |
1006 | 1009 | "\n", |
1007 | 1010 | "# Step 2: Create a new parameter `min_anzahl_kinder_für_kinderfreibetrag`\n", |
1008 | | - "from gettsim.tt import ScalarParam, Unit\n", |
| 1011 | + "from gettsim.tt import ScalarParam, TTSIMUnit\n", |
1009 | 1012 | "\n", |
1010 | 1013 | "min_anzahl_kinder_für_kinderfreibetrag = ScalarParam(\n", |
1011 | | - " value=2, unit=Unit.PERSON_COUNT.PER_FG\n", |
| 1014 | + " value=2, unit=TTSIMUnit.PERSON_COUNT\n", |
1012 | 1015 | ")\n", |
1013 | 1016 | "\n", |
1014 | 1017 | "# Step 3: Create a new `PolicyFunction` that modifies the tax deduction for children\n", |
1015 | 1018 | "# based on the new parameter\n", |
1016 | 1019 | "from gettsim.tt import policy_function\n", |
1017 | 1020 | "\n", |
1018 | 1021 | "\n", |
1019 | | - "@policy_function(unit=Unit.CURRENCY.PER_YEAR)\n", |
| 1022 | + "@policy_function(unit=TTSIMUnit.CURRENCY.PER_YEAR)\n", |
1020 | 1023 | "def kinderfreibetrag_y(\n", |
1021 | 1024 | " anzahl_kinderfreibeträge: int,\n", |
1022 | 1025 | " kinderfreibetrag_pro_kind_y: float,\n", |
|
0 commit comments