policyengine 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. policyengine-0.1.1/.github/CONTRIBUTING.md +14 -0
  2. policyengine-0.1.1/.github/changelog_template.md +8 -0
  3. policyengine-0.1.1/.github/fetch_version.py +13 -0
  4. policyengine-0.1.1/.github/get-changelog-diff.sh +2 -0
  5. policyengine-0.1.1/.github/has-functional-changes.sh +12 -0
  6. policyengine-0.1.1/.github/is-version-number-acceptable.sh +33 -0
  7. policyengine-0.1.1/.github/publish-git-tag.sh +4 -0
  8. policyengine-0.1.1/.github/workflows/any_changes.yaml +40 -0
  9. policyengine-0.1.1/.github/workflows/code_changes.yaml +41 -0
  10. policyengine-0.1.1/.github/workflows/publish_documentation.yaml +33 -0
  11. policyengine-0.1.1/.github/workflows/publish_package.yaml +47 -0
  12. policyengine-0.1.1/.github/workflows/versioning.yaml +37 -0
  13. policyengine-0.1.1/.gitignore +164 -0
  14. policyengine-0.1.1/CHANGELOG.md +22 -0
  15. policyengine-0.1.1/LICENSE +661 -0
  16. policyengine-0.1.1/Makefile +25 -0
  17. policyengine-0.1.1/PKG-INFO +689 -0
  18. policyengine-0.1.1/README.md +3 -0
  19. policyengine-0.1.1/changelog.yaml +10 -0
  20. policyengine-0.1.1/changelog_entry.yaml +0 -0
  21. policyengine-0.1.1/docs/.DS_Store +0 -0
  22. policyengine-0.1.1/docs/_config.yml +31 -0
  23. policyengine-0.1.1/docs/_static/style.css +5 -0
  24. policyengine-0.1.1/docs/_toc.yml +22 -0
  25. policyengine-0.1.1/docs/add_plotly_to_book.py +27 -0
  26. policyengine-0.1.1/docs/basic/calculate_economy_comparison.ipynb +277 -0
  27. policyengine-0.1.1/docs/basic/calculate_household_comparison.ipynb +156 -0
  28. policyengine-0.1.1/docs/basic/calculate_single_economy.ipynb +157 -0
  29. policyengine-0.1.1/docs/basic/calculate_single_household.ipynb +122 -0
  30. policyengine-0.1.1/docs/basic/create_charts.ipynb +5191 -0
  31. policyengine-0.1.1/docs/concepts/extending.ipynb +69 -0
  32. policyengine-0.1.1/docs/concepts/simulation.ipynb +140 -0
  33. policyengine-0.1.1/docs/index.ipynb +81 -0
  34. policyengine-0.1.1/docs/logo.png +0 -0
  35. policyengine-0.1.1/docs/outputs/calculate_average_earnings.md +7 -0
  36. policyengine-0.1.1/docs/reference/parameters_uk.md +6762 -0
  37. policyengine-0.1.1/docs/reference/parameters_us.md +13997 -0
  38. policyengine-0.1.1/docs/reference/uk_parameters.ipynb +87 -0
  39. policyengine-0.1.1/docs/reference/us_parameters.ipynb +85 -0
  40. policyengine-0.1.1/policyengine/__init__.py +3 -0
  41. policyengine-0.1.1/policyengine/constants.py +14 -0
  42. policyengine-0.1.1/policyengine/outputs/household/__init__.py +0 -0
  43. policyengine-0.1.1/policyengine/outputs/household/comparison/__init__.py +0 -0
  44. policyengine-0.1.1/policyengine/outputs/household/comparison/calculate_household_comparison.py +53 -0
  45. policyengine-0.1.1/policyengine/outputs/household/single/__init__.py +0 -0
  46. policyengine-0.1.1/policyengine/outputs/household/single/calculate_single_household.py +203 -0
  47. policyengine-0.1.1/policyengine/outputs/macro/__init__.py +0 -0
  48. policyengine-0.1.1/policyengine/outputs/macro/comparison/__init__.py +0 -0
  49. policyengine-0.1.1/policyengine/outputs/macro/comparison/calculate_economy_comparison.py +110 -0
  50. policyengine-0.1.1/policyengine/outputs/macro/comparison/charts/__init__.py +5 -0
  51. policyengine-0.1.1/policyengine/outputs/macro/comparison/charts/budget.py +90 -0
  52. policyengine-0.1.1/policyengine/outputs/macro/comparison/charts/budget_by_program.py +96 -0
  53. policyengine-0.1.1/policyengine/outputs/macro/comparison/charts/decile.py +89 -0
  54. policyengine-0.1.1/policyengine/outputs/macro/comparison/charts/inequality.py +77 -0
  55. policyengine-0.1.1/policyengine/outputs/macro/comparison/charts/winners_losers.py +148 -0
  56. policyengine-0.1.1/policyengine/outputs/macro/comparison/decile.py +209 -0
  57. policyengine-0.1.1/policyengine/outputs/macro/single/__init__.py +2 -0
  58. policyengine-0.1.1/policyengine/outputs/macro/single/budget.py +82 -0
  59. policyengine-0.1.1/policyengine/outputs/macro/single/calculate_average_earnings.py +9 -0
  60. policyengine-0.1.1/policyengine/outputs/macro/single/calculate_single_economy.py +39 -0
  61. policyengine-0.1.1/policyengine/outputs/macro/single/inequality.py +53 -0
  62. policyengine-0.1.1/policyengine/simulation.py +330 -0
  63. policyengine-0.1.1/policyengine/utils/__init__.py +0 -0
  64. policyengine-0.1.1/policyengine/utils/budget.py +72 -0
  65. policyengine-0.1.1/policyengine/utils/calculations.py +56 -0
  66. policyengine-0.1.1/policyengine/utils/charts.py +199 -0
  67. policyengine-0.1.1/policyengine/utils/huggingface.py +27 -0
  68. policyengine-0.1.1/policyengine/utils/maps.py +110 -0
  69. policyengine-0.1.1/policyengine/utils/reforms.py +19 -0
  70. policyengine-0.1.1/policyengine.egg-info/PKG-INFO +689 -0
  71. policyengine-0.1.1/policyengine.egg-info/SOURCES.txt +78 -0
  72. policyengine-0.1.1/policyengine.egg-info/dependency_links.txt +1 -0
  73. policyengine-0.1.1/policyengine.egg-info/requires.txt +16 -0
  74. policyengine-0.1.1/policyengine.egg-info/top_level.txt +1 -0
  75. policyengine-0.1.1/pyproject.toml +65 -0
  76. policyengine-0.1.1/setup.cfg +4 -0
  77. policyengine-0.1.1/tests/country/test_average_earnings.py +11 -0
  78. policyengine-0.1.1/tests/country/test_uk.py +23 -0
  79. policyengine-0.1.1/tests/country/test_us.py +23 -0
  80. policyengine-0.1.1/tests/test_package.py +2 -0
@@ -0,0 +1,14 @@
1
+ ## Updating the versioning
2
+
3
+ Please add to `changelog_entry.yaml` an entry in the format:
4
+
5
+ ```yaml
6
+ - bump: minor
7
+ changes:
8
+ added:
9
+ - New feature.
10
+ fixed:
11
+ - Bug fix.
12
+ changed:
13
+ - Change.
14
+ ```
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ {{changelog}}
@@ -0,0 +1,13 @@
1
+ def fetch_version():
2
+ try:
3
+ import importlib
4
+
5
+ return importlib.import_module("policyengine").__version__
6
+ return version
7
+ except Exception as e:
8
+ print(f"Error fetching version: {e}")
9
+ return None
10
+
11
+
12
+ if __name__ == "__main__":
13
+ print(fetch_version())
@@ -0,0 +1,2 @@
1
+ last_tagged_commit=`git describe --tags --abbrev=0 --first-parent`
2
+ git --no-pager diff $last_tagged_commit -- CHANGELOG.md
@@ -0,0 +1,12 @@
1
+ #! /usr/bin/env bash
2
+
3
+ IGNORE_DIFF_ON="README.md CONTRIBUTING.md Makefile docs/* .gitignore LICENSE* .github/* data/*"
4
+
5
+ last_tagged_commit=`git describe --tags --abbrev=0 --first-parent` # --first-parent ensures we don't follow tags not published in master through an unlikely intermediary merge commit
6
+
7
+ if git diff-index --name-only --exit-code $last_tagged_commit -- . `echo " $IGNORE_DIFF_ON" | sed 's/ / :(exclude)/g'` # Check if any file that has not be listed in IGNORE_DIFF_ON has changed since the last tag was published.
8
+ then
9
+ echo "No functional changes detected."
10
+ exit 1
11
+ else echo "The functional files above were changed."
12
+ fi
@@ -0,0 +1,33 @@
1
+ #! /usr/bin/env bash
2
+
3
+ if [[ ${GITHUB_REF#refs/heads/} == master ]]
4
+ then
5
+ echo "No need for a version check on master."
6
+ exit 0
7
+ fi
8
+
9
+ if ! $(dirname "$BASH_SOURCE")/has-functional-changes.sh
10
+ then
11
+ echo "No need for a version update."
12
+ exit 0
13
+ fi
14
+
15
+ current_version=`python .github/fetch_version.py`
16
+
17
+ if git rev-parse --verify --quiet $current_version
18
+ then
19
+ echo "Version $current_version already exists in commit:"
20
+ git --no-pager log -1 $current_version
21
+ echo
22
+ echo "Update the version number in setup.py before merging this branch into master."
23
+ echo "Look at the CONTRIBUTING.md file to learn how the version number should be updated."
24
+ exit 1
25
+ fi
26
+
27
+ if ! $(dirname "$BASH_SOURCE")/has-functional-changes.sh | grep --quiet CHANGELOG.md
28
+ then
29
+ echo "CHANGELOG.md has not been modified, while functional changes were made."
30
+ echo "Explain what you changed before merging this branch into master."
31
+ echo "Look at the CONTRIBUTING.md file to learn how to write the changelog."
32
+ exit 2
33
+ fi
@@ -0,0 +1,4 @@
1
+ #! /usr/bin/env bash
2
+
3
+ git tag `python .github/fetch_version.py` # create a new tag
4
+ git push --tags || true # update the repository version
@@ -0,0 +1,40 @@
1
+ # Workflow that runs on code changes to a pull request.
2
+
3
+ name: Any changes
4
+ on:
5
+ pull_request:
6
+ branches:
7
+ - main
8
+
9
+ jobs:
10
+ docs:
11
+ name: Test documentation builds
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - name: Checkout repo
15
+ uses: actions/checkout@v2
16
+ - name: Install uv
17
+ uses: astral-sh/setup-uv@v5
18
+
19
+ - name: Set up Python
20
+ uses: actions/setup-python@v2
21
+ with:
22
+ python-version: '3.11'
23
+
24
+ - name: Install package
25
+ run: uv pip install .[dev] --system
26
+
27
+ - name: Test documentation builds
28
+ run: make documentation
29
+ env:
30
+ HUGGING_FACE_TOKEN: ${{ secrets.HUGGING_FACE_TOKEN }}
31
+
32
+ - name: Check documentation build
33
+ run: |
34
+ for notebook in $(find docs/_build/jupyter_execute -name "*.ipynb"); do
35
+ if grep -q '"output_type": "error"' "$notebook"; then
36
+ echo "Error found in $notebook"
37
+ cat "$notebook"
38
+ exit 1
39
+ fi
40
+ done
@@ -0,0 +1,41 @@
1
+ # Workflow that runs on code changes to a pull request.
2
+
3
+ name: Code changes
4
+ on:
5
+ pull_request:
6
+ branches:
7
+ - main
8
+
9
+ paths:
10
+ - policyengine/**
11
+ - tests/**
12
+
13
+ jobs:
14
+ Lint:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - name: Check formatting
19
+ uses: "lgeiger/black-action@master"
20
+ with:
21
+ args: ". -l 79 --check"
22
+ Test:
23
+ runs-on: ubuntu-latest
24
+ steps:
25
+ - name: Checkout repo
26
+ uses: actions/checkout@v2
27
+ - name: Install uv
28
+ uses: astral-sh/setup-uv@v5
29
+
30
+ - name: Set up Python
31
+ uses: actions/setup-python@v2
32
+ with:
33
+ python-version: '3.11'
34
+
35
+ - name: Install package
36
+ run: uv pip install .[dev] --system
37
+
38
+ - name: Run tests
39
+ run: make test
40
+ env:
41
+ HUGGING_FACE_TOKEN: ${{ secrets.HUGGING_FACE_TOKEN }}
@@ -0,0 +1,33 @@
1
+ name: Publish documentation
2
+ on:
3
+ push:
4
+ branches: [ main ]
5
+ paths:
6
+ - docs/** # Only run workflow when documentation changes
7
+
8
+ jobs:
9
+ Publish:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Checkout repo
13
+ uses: actions/checkout@v4
14
+ - name: Setup Python
15
+ uses: actions/setup-python@v5
16
+ with:
17
+ python-version: 3.12
18
+ - name: Publish a git tag
19
+ run: ".github/publish-git-tag.sh || true"
20
+ - name: Install package
21
+ run: make install
22
+
23
+ - name: Build documentation
24
+ run: make documentation
25
+ env:
26
+ HUGGING_FACE_TOKEN: ${{ secrets.HUGGING_FACE_TOKEN }}
27
+
28
+ - name: Deploy documentation
29
+ uses: JamesIves/github-pages-deploy-action@releases/v3
30
+ with:
31
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32
+ BRANCH: gh-pages # The branch the action should deploy to.
33
+ FOLDER: docs/_build/html # The folder the action should deploy.
@@ -0,0 +1,47 @@
1
+ name: Publish package
2
+ on:
3
+ push:
4
+ branches: [ main ]
5
+ paths:
6
+ - pyproject.toml
7
+
8
+ jobs:
9
+ Publish:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Checkout repo
13
+ uses: actions/checkout@v2
14
+ - name: Install uv
15
+ uses: astral-sh/setup-uv@v5
16
+
17
+ - name: Set up Python
18
+ uses: actions/setup-python@v2
19
+ with:
20
+ python-version: '3.11'
21
+ - name: Publish a git tag
22
+ run: ".github/publish-git-tag.sh || true"
23
+ - name: Install package
24
+ run: make install
25
+ - name: Build package
26
+ run: make
27
+ - name: Remove .whl files
28
+ run: rm dist/*.whl
29
+ - name: Publish a Python distribution to PyPI
30
+ uses: pypa/gh-action-pypi-publish@release/v1
31
+ with:
32
+ user: __token__
33
+ password: ${{ secrets.PYPI }}
34
+ skip-existing: true
35
+ verbose: true
36
+
37
+ - name: Test documentation builds
38
+ run: make documentation
39
+ env:
40
+ HUGGING_FACE_TOKEN: ${{ secrets.HUGGING_FACE_TOKEN }}
41
+
42
+ - name: Deploy documentation
43
+ uses: JamesIves/github-pages-deploy-action@releases/v3
44
+ with:
45
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46
+ BRANCH: gh-pages # The branch the action should deploy to.
47
+ FOLDER: docs/_build/html # The folder the action should deploy.
@@ -0,0 +1,37 @@
1
+ # Workflow that runs on versioning metadata updates.
2
+
3
+ name: Versioning updates
4
+ on:
5
+ push:
6
+ branches:
7
+ - main
8
+
9
+ paths:
10
+ - changelog_entry.yaml
11
+ - "!pyproject.toml"
12
+
13
+ jobs:
14
+ Versioning:
15
+ runs-on: ubuntu-latest
16
+ if: |
17
+ (!(github.event.head_commit.message == 'Update package version'))
18
+ steps:
19
+ - name: Checkout repo
20
+ uses: actions/checkout@v4
21
+ with:
22
+ repository: ${{ github.event.pull_request.head.repo.full_name }}
23
+ ref: ${{ github.event.pull_request.head.ref }}
24
+ token: ${{ secrets.POLICYENGINE_GITHUB }}
25
+ - name: Setup Python
26
+ uses: actions/setup-python@v5
27
+ with:
28
+ python-version: 3.12
29
+ - name: Build changelog
30
+ run: pip install yaml-changelog && make changelog
31
+ - name: Preview changelog update
32
+ run: ".github/get-changelog-diff.sh"
33
+ - name: Update changelog
34
+ uses: EndBug/add-and-commit@v9
35
+ with:
36
+ add: "."
37
+ message: Update package version
@@ -0,0 +1,164 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/#use-with-ide
110
+ .pdm.toml
111
+
112
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
+ __pypackages__/
114
+
115
+ # Celery stuff
116
+ celerybeat-schedule
117
+ celerybeat.pid
118
+
119
+ # SageMath parsed files
120
+ *.sage.py
121
+
122
+ # Environments
123
+ .env
124
+ .venv
125
+ env/
126
+ venv/
127
+ ENV/
128
+ env.bak/
129
+ venv.bak/
130
+
131
+ # Spyder project settings
132
+ .spyderproject
133
+ .spyproject
134
+
135
+ # Rope project settings
136
+ .ropeproject
137
+
138
+ # mkdocs documentation
139
+ /site
140
+
141
+ # mypy
142
+ .mypy_cache/
143
+ .dmypy.json
144
+ dmypy.json
145
+
146
+ # Pyre type checker
147
+ .pyre/
148
+
149
+ # pytype static type analyzer
150
+ .pytype/
151
+
152
+ # Cython debug symbols
153
+ cython_debug/
154
+
155
+ # PyCharm
156
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
159
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160
+ #.idea/
161
+
162
+ *.ipynb
163
+
164
+ !docs/**/*.ipynb
@@ -0,0 +1,22 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.1] - 2025-02-21 14:02:22
9
+
10
+ ### Fixed
11
+
12
+ - Dependency for `pkg_resources`.
13
+
14
+ ## [0.1.0] - 2024-11-30 00:00:00
15
+
16
+ ### Added
17
+
18
+ - Initial version of package.
19
+
20
+
21
+
22
+ [0.1.1]: https://github.com/PolicyEngine/policyengine.py/compare/0.1.0...0.1.1