Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/collect-components-of-namespaces…
Browse files Browse the repository at this point in the history
…' into namespaces-renamings
  • Loading branch information
MImmesberger committed Feb 18, 2025
2 parents 7b56870 + 6c6c015 commit 0a29c3b
Show file tree
Hide file tree
Showing 93 changed files with 7,137 additions and 11,481 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ jobs:
environment: py311
steps:
- uses: actions/checkout@v4
- uses: prefix-dev/[email protected].1
- uses: prefix-dev/[email protected].2
with:
pixi-version: v0.34.0
pixi-version: v0.41.1
cache: true
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
frozen: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-to-pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ jobs:
name: Build and publish Python 🐍 distributions 📦 to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install pypa/build
Expand Down
23 changes: 0 additions & 23 deletions MANIFEST.in

This file was deleted.

12 changes: 6 additions & 6 deletions docs/geps/gep-05.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,17 @@ following elements:
In the same way as other policy parameters, the rounding parameters become part of the
dictionary `policy_params`.

A function to be rounded must be decorated with `policy_info`. Set the
A function to be rounded must be decorated with `policy_function`. Set the
`params_key_for_rounding` parameter to point to the key of the policy parameters
dictionary containing the rounding parameters relating to the function that is
decorated. In the above example, the rounding specification for
`grundr_zuschlag_höchstwert_m` will be found in `policy_params["ges_rente"]` after
{func}`set_up_policy_environment()` has been called (since it was specified in
`ges_rente.yaml`). Hence, the `params_key_for_rounding` argument of `policy_info` has to
be `"ges_rente"`:
`ges_rente.yaml`). Hence, the `params_key_for_rounding` argument of `policy_function`
has to be `"ges_rente"`:

```python
@policy_info(params_key_for_rounding="ges_rente")
@policy_function(params_key_for_rounding="ges_rente")
def grundr_zuschlag_höchstwert_m(grundr_zeiten: int) -> float:
...
return out
Expand Down Expand Up @@ -138,8 +138,8 @@ This will be done after the policy environment has been set up and it is exactly
same as for other parameters of the taxes and transfers system, see {ref}`gep-3`.

If a user would like to add user-written functions which should be rounded, she will
need to decorate the respective functions with `policy_info` and adjust `policy_params`
accordingly.
need to decorate the respective functions with `policy_function` and adjust
`policy_params` accordingly.

## Advantages of this implementation

Expand Down
5 changes: 4 additions & 1 deletion docs/gettsim_developer/how-to-contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@ To contribute to the project, adhere to the following process.
they pass our test suite which can be started with the following command.

```shell-session
$ pixi run pytest
$ pixi run tests
```

which will prompt you to choose a python version to run the tests with. You may choose
the most recent one; both will be checked in our CI testing.

Sometimes you want to push changes even if the tests fail because you need feedback.
Then, skip this step.

Expand Down
6 changes: 3 additions & 3 deletions docs/how_to_guides/calculating_elterngeld.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
"outputs": [],
"source": [
"from gettsim import (\n",
" PolicyEnvironment,\n",
" compute_taxes_and_transfers,\n",
" create_synthetic_data,\n",
" set_up_policy_environment,\n",
")"
]
},
Expand Down Expand Up @@ -128,7 +128,7 @@
"metadata": {},
"outputs": [],
"source": [
"environment_2023 = PolicyEnvironment.for_date(2023)\n",
"environment_2023 = set_up_policy_environment(2023)\n",
"\n",
"net_wage_approximation = compute_taxes_and_transfers(\n",
" data=data_before_birth,\n",
Expand Down Expand Up @@ -208,7 +208,7 @@
"metadata": {},
"outputs": [],
"source": [
"environment_2024 = PolicyEnvironment.for_date(\"2024-07-01\")\n",
"environment_2024 = set_up_policy_environment(\"2024-07-01\")\n",
"\n",
"# Compute Elterngeld\n",
"results = compute_taxes_and_transfers(\n",
Expand Down
2 changes: 2 additions & 0 deletions docs/rtd_environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ dependencies:
- sphinx-copybutton
- pip:
- -e ../
- git+https://github.com/OpenSourceEconomics/dags
- flatten_dict
33 changes: 3 additions & 30 deletions docs/tutorials/advanced_usage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"\n",
"This tutorial showcases advanced functionalities and applications of GETTSIM's interface. For an introductory tutorial see [here](basic_usage.ipynb). The introductory tutorial showcases GETTSIM's two main functions using a minimal working example:\n",
"\n",
"1. `PolicyEnvironment.for_date` which loads a policy environment for a specified date.\n",
"1. `set_up_policy_environment` which loads a policy environment for a specified date.\n",
"\n",
"2. `compute_taxes_and_transfers` which allows you to compute taxes and transfers given a specified policy environment for household or individual observations.\n",
"\n",
Expand All @@ -29,10 +29,10 @@
"\n",
"from gettsim import (\n",
" FunctionsAndColumnsOverlapWarning,\n",
" PolicyEnvironment,\n",
" compute_taxes_and_transfers,\n",
" create_synthetic_data,\n",
" plot_dag,\n",
" set_up_policy_environment,\n",
")\n",
"\n",
"warnings.filterwarnings(\"ignore\", category=FunctionsAndColumnsOverlapWarning)"
Expand All @@ -56,7 +56,7 @@
"metadata": {},
"outputs": [],
"source": [
"environment = PolicyEnvironment.for_date(2020)"
"environment = set_up_policy_environment(2020)"
]
},
{
Expand Down Expand Up @@ -287,33 +287,6 @@
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Error Messages and Warnings: Unused Inputs\n",
"\n",
"The function `compute_taxes_and_transfers` also has an option that allows you to check for unused inputs in your data. This functionality is controlled through the argument `check_minimal_specification`. By default, it is set to `ignore`, meaning no check is conduced. However, it can also be set to `warn` to trigger a warning or `raise` an error that includes a message stating the unused inputs."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"raises-exception"
]
},
"outputs": [],
"source": [
"result = compute_taxes_and_transfers(\n",
" data=data,\n",
" environment=environment,\n",
" targets=\"kindergeld_m\",\n",
" check_minimal_specification=\"raise\",\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
14 changes: 5 additions & 9 deletions docs/tutorials/basic_usage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
"import json\n",
"\n",
"from gettsim import (\n",
" PolicyEnvironment,\n",
" compute_taxes_and_transfers,\n",
" create_synthetic_data,\n",
" set_up_policy_environment,\n",
")"
]
},
Expand All @@ -44,19 +44,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Loading Policies with `PolicyEnvironment.for_date`"
"## Loading Policies with `set_up_policy_environment`"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"The function `PolicyEnvironment.for_date` allows you to load the policy environment in Germany for a given date. The function returns an object that composes\n",
"\n",
"- `params` which is a dictionary containing date-specific parameters for the policy environment.\n",
"\n",
"- `functions` which is a dictionary containing functions that are necessary to compute quantities in the taxes and transfers system on the provided date and data.\n",
"The function `set_up_policy_environment` allows you to load the policy environment in Germany for a given date. The function returns an `PolicyEnvironment` object.\n",
"\n",
"Below, we load the policy environment for the year 2020. The exact date for this input will be January 1st, 2020. An exact date would be accepted as an input, too."
]
Expand All @@ -67,7 +63,7 @@
"metadata": {},
"outputs": [],
"source": [
"environment = PolicyEnvironment.for_date(2020)"
"environment = set_up_policy_environment(2020)"
]
},
{
Expand Down Expand Up @@ -146,7 +142,7 @@
"source": [
"### Specifying the Date\n",
"\n",
"Dates can be specified in various ways. The function `PolicyEnvironment.for_date` accepts objects of type str, int, and [datetime](https://docs.python.org/3/library/datetime.html) as inputs to specify a date. If only a year is specified, the policy date will be set to the first day of the year i.e. the inputs `\"2020\"` and `2020` will both return the policy environment for January 1st, 2020. The input `\"2020/03\"` on the other hand will set up the policy environment for March 1st, 2020 since a month and year are specified. Lastly, it is also possible to use a specific day such as `\"2020/03/21\"`, which will return the policy environment for March 21st, 2020."
"Dates can be specified in various ways. The function `set_up_policy_environment` accepts objects of type str, int, and [datetime](https://docs.python.org/3/library/datetime.html) as inputs to specify a date. If only a year is specified, the policy date will be set to the first day of the year i.e. the inputs `\"2020\"` and `2020` will both return the policy environment for January 1st, 2020. The input `\"2020/03\"` on the other hand will set up the policy environment for March 1st, 2020 since a month and year are specified. Lastly, it is also possible to use a specific day such as `\"2020/03/21\"`, which will return the policy environment for March 21st, 2020."
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/debugging.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"source": [
"import pandas as pd\n",
"\n",
"from gettsim import PolicyEnvironment, compute_taxes_and_transfers"
"from gettsim import compute_taxes_and_transfers, set_up_policy_environment"
]
},
{
Expand Down Expand Up @@ -53,7 +53,7 @@
"metadata": {},
"outputs": [],
"source": [
"environment = PolicyEnvironment.for_date(2020)"
"environment = set_up_policy_environment(2020)"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/parameters.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"import plotly.express as px\n",
"\n",
"from gettsim import (\n",
" PolicyEnvironment,\n",
" compute_taxes_and_transfers,\n",
" create_synthetic_data,\n",
" set_up_policy_environment,\n",
")"
]
},
Expand All @@ -52,7 +52,7 @@
"source": [
"## Finding the Relevant Parameter\n",
"\n",
"Firstly, we can load the existing policy environment for the year 2020 using the function `PolicyEnvironment.for_date`."
"Firstly, we can load the existing policy environment for the year 2020 using the function `set_up_policy_environment`."
]
},
{
Expand All @@ -61,7 +61,7 @@
"metadata": {},
"outputs": [],
"source": [
"environment = PolicyEnvironment.for_date(2020)"
"environment = set_up_policy_environment(2020)"
]
},
{
Expand Down
10 changes: 5 additions & 5 deletions docs/tutorials/policy_functions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
"\n",
"from gettsim import (\n",
" FunctionsAndColumnsOverlapWarning,\n",
" PolicyEnvironment,\n",
" compute_taxes_and_transfers,\n",
" create_synthetic_data,\n",
" set_up_policy_environment,\n",
")\n",
"\n",
"warnings.filterwarnings(\"ignore\", category=FunctionsAndColumnsOverlapWarning)"
Expand Down Expand Up @@ -57,7 +57,7 @@
"metadata": {},
"outputs": [],
"source": [
"environment = PolicyEnvironment.for_date(2020)"
"environment = set_up_policy_environment(2020)"
]
},
{
Expand Down Expand Up @@ -338,11 +338,11 @@
"\n",
"If we would like to add (or replace) such functions, we need to specify them in a\n",
"dictionary which we provide to `compute_taxes_and_transfers` via the\n",
"`aggregate_by_group_specs` argument. An example dictionary is as follows:\n",
"`aggregate_by_group_specs_tree` argument. An example dictionary is as follows:\n",
"\n",
"\n",
"```python\n",
"aggregate_by_group_specs = {\n",
"aggregate_by_group_specs_tree = {\n",
" \"anz_erwachsene_sn\": {\"source_col\": \"erwachsen\", \"aggr\": \"sum\"},\n",
" \"anz_personen_hh\": {\"aggr\": \"count\"},\n",
"}\n",
Expand All @@ -351,7 +351,7 @@
"### Aggregation Based on `p_id`\n",
"\n",
"Similarly to above, aggregation functions based on `p_id` are specified in a dictionary\n",
"which can be provided to `compute_taxes_and_transfers` via the `aggregate_by_p_id_specs`\n",
"which can be provided to `compute_taxes_and_transfers` via the `aggregate_by_p_id_specs_tree`\n",
"argument. An example dictionary is as follows:\n",
"\n",
"```python\n",
Expand Down
Loading

0 comments on commit 0a29c3b

Please sign in to comment.