normschores 0.1.0__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 (50) hide show
  1. normschores-0.1.0/PKG-INFO +166 -0
  2. normschores-0.1.0/README.md +143 -0
  3. normschores-0.1.0/pyproject.toml +68 -0
  4. normschores-0.1.0/pyproject.toml.orig +73 -0
  5. normschores-0.1.0/src/normschores/Chorms.py +1103 -0
  6. normschores-0.1.0/src/normschores/LocalEconModel/EconModel.py +363 -0
  7. normschores-0.1.0/src/normschores/LocalEconModel/__init__.py +2 -0
  8. normschores-0.1.0/src/normschores/LocalEconModel/cppcompile.py +396 -0
  9. normschores-0.1.0/src/normschores/LocalEconModel/cppstruct.py +283 -0
  10. normschores-0.1.0/src/normschores/LocalEconModel/cpptools.py +468 -0
  11. normschores-0.1.0/src/normschores/LocalEconModel/jit.py +50 -0
  12. normschores-0.1.0/src/normschores/__init__.py +10 -0
  13. normschores-0.1.0/src/normschores/_notebooks.py +64 -0
  14. normschores-0.1.0/src/normschores/cppfuncs/logs.cpp +41 -0
  15. normschores-0.1.0/src/normschores/cppfuncs/model_cpp.cpp +217 -0
  16. normschores-0.1.0/src/normschores/cppfuncs/myheader.h +44 -0
  17. normschores-0.1.0/src/normschores/cppfuncs/nlopt-2.4.2-dll64/COPYING +40 -0
  18. normschores-0.1.0/src/normschores/cppfuncs/nlopt-2.4.2-dll64/COPYRIGHT +22 -0
  19. normschores-0.1.0/src/normschores/cppfuncs/nlopt-2.4.2-dll64/NEWS +347 -0
  20. normschores-0.1.0/src/normschores/cppfuncs/nlopt-2.4.2-dll64/README +39 -0
  21. normschores-0.1.0/src/normschores/cppfuncs/nlopt-2.4.2-dll64/README-WINDOWS +18 -0
  22. normschores-0.1.0/src/normschores/cppfuncs/nlopt-2.4.2-dll64/libnlopt-0.def +247 -0
  23. normschores-0.1.0/src/normschores/cppfuncs/nlopt-2.4.2-dll64/libnlopt-0.dll +0 -0
  24. normschores-0.1.0/src/normschores/cppfuncs/nlopt-2.4.2-dll64/libnlopt-0.exp +0 -0
  25. normschores-0.1.0/src/normschores/cppfuncs/nlopt-2.4.2-dll64/libnlopt-0.lib +0 -0
  26. normschores-0.1.0/src/normschores/cppfuncs/nlopt-2.4.2-dll64/nlopt-python.cpp +13520 -0
  27. normschores-0.1.0/src/normschores/cppfuncs/nlopt-2.4.2-dll64/nlopt.f +108 -0
  28. normschores-0.1.0/src/normschores/cppfuncs/nlopt-2.4.2-dll64/nlopt.h +381 -0
  29. normschores-0.1.0/src/normschores/cppfuncs/nlopt-2.4.2-dll64/nlopt.hpp +596 -0
  30. normschores-0.1.0/src/normschores/cppfuncs/nlopt-2.4.2-dll64/nlopt.py +337 -0
  31. normschores-0.1.0/src/normschores/cppfuncs/nlopt-2.4.2-dll64/setup.py +14 -0
  32. normschores-0.1.0/src/normschores/cppfuncs/par_struct.cpp +156 -0
  33. normschores-0.1.0/src/normschores/cppfuncs/sim_struct.cpp +65 -0
  34. normschores-0.1.0/src/normschores/cppfuncs/sol_struct.cpp +53 -0
  35. normschores-0.1.0/src/normschores/cppfuncs/utils.cpp +675 -0
  36. normschores-0.1.0/src/normschores/estimate/SMD.py +583 -0
  37. normschores-0.1.0/src/normschores/estimate/__init__.py +0 -0
  38. normschores-0.1.0/src/normschores/estimate/bootstrap_cov.py +249 -0
  39. normschores-0.1.0/src/normschores/estimate/draw.py +94 -0
  40. normschores-0.1.0/src/normschores/estimate/moments.py +458 -0
  41. normschores-0.1.0/src/normschores/estimate/sobol.py +980 -0
  42. normschores-0.1.0/src/normschores/exhibits.py +489 -0
  43. normschores-0.1.0/src/normschores/notebooks/0.5_Descriptives.ipynb +1313 -0
  44. normschores-0.1.0/src/normschores/notebooks/0_DataMoments.ipynb +648 -0
  45. normschores-0.1.0/src/normschores/notebooks/1_EstimateModel.ipynb +908 -0
  46. normschores-0.1.0/src/normschores/notebooks/2_ModelFit.ipynb +1009 -0
  47. normschores-0.1.0/src/normschores/notebooks/3_Counterfactuals.ipynb +2131 -0
  48. normschores-0.1.0/src/normschores/notebooks/4_Sensitivity.ipynb +2884 -0
  49. normschores-0.1.0/src/normschores/notebooks/TestSolution.ipynb +568 -0
  50. normschores-0.1.0/src/normschores/notebooks/_ Run all notebooks.ipynb +194 -0
@@ -0,0 +1,166 @@
1
+ Metadata-Version: 2.3
2
+ Name: normschores
3
+ Version: 0.1.0
4
+ Summary: Structural household model of gender norms and the division of market work, chores and leisure.
5
+ Author: Thomas H. Jørgensen, Adam Hallengreen
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Programming Language :: C++
8
+ Classifier: Operating System :: Microsoft :: Windows
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: Topic :: Scientific/Engineering
11
+ Requires-Dist: matplotlib>=3.11.1
12
+ Requires-Dist: numpy>=2.5.1
13
+ Requires-Dist: pandas>=3.0.5
14
+ Requires-Dist: polars>=1.44
15
+ Requires-Dist: pyfixest>=0.60
16
+ Requires-Dist: scipy>=1.18.0
17
+ Requires-Dist: ipykernel>=7.3.0 ; extra == 'notebooks'
18
+ Requires-Dist: papermill>=2.6.0 ; extra == 'notebooks'
19
+ Requires-Python: >=3.12
20
+ Project-URL: Repository, https://github.com/ThomasHJorgensen/NormsChores
21
+ Provides-Extra: notebooks
22
+ Description-Content-Type: text/markdown
23
+
24
+ # normschores
25
+
26
+ Code for the NormsChores project: a structural household model of gender norms and the division of
27
+ market work, chores and leisure, with simulated-minimum-distance estimation tools.
28
+
29
+ The Python package lives in `src/normschores/`:
30
+
31
+ | module | contents |
32
+ | --- | --- |
33
+ | `normschores.Chorms` | `ChormsClass`, the model (solved in C++, see `cppfuncs/`) |
34
+ | `normschores.estimate` | moments (`moments`), bootstrap covariance (`bootstrap_cov`), SMD estimator (`SMD`) |
35
+ | `normschores.exhibits` | figures and tables for the paper |
36
+ | `normschores.LocalEconModel` | vendored copy of [EconModel](https://github.com/NumEconCopenhagen/EconModel) used for the C++ linking |
37
+ | `normschores/notebooks/` | the notebooks that reproduce the paper (`0_DataMoments.ipynb`, `1_EstimateModel.ipynb`, ..., `_ Run all notebooks.ipynb`) |
38
+
39
+ ## Requirements
40
+
41
+ **Windows only.** The model is solved in C++ which is compiled on first use with Microsoft Visual
42
+ Studio (2019/2022 Community is found automatically; for other editions set `COMPILER_PATH` in the
43
+ notebooks, or pass `ChormsClass(..., compiler_path="<VS>/VC/Auxiliary/Build/")`). The compiled
44
+ `model_cpp.dll` is written to the current working directory. Python 3.12 or newer.
45
+
46
+ ## Running the notebooks from the published package
47
+
48
+ Create a fresh virtual environment, install the package with the `notebooks` extra (adds `ipykernel`
49
+ and `papermill`) and copy the notebooks to a working folder. The notebooks write their results
50
+ (`saved/`, `output/figures/`, `output/tables/`) relative to the folder they are run from, so always
51
+ run them from such a copy, never from inside the installed package.
52
+
53
+ With [uv](https://docs.astral.sh/uv/):
54
+
55
+ ```bash
56
+ uv venv --python 3.12 .venv
57
+ .venv\Scripts\activate
58
+ uv pip install "normschores[notebooks]"
59
+ normschores-notebooks my_run # copies the notebooks to .\my_run
60
+ ```
61
+
62
+ or with plain pip:
63
+
64
+ ```bash
65
+ py -3.12 -m venv .venv
66
+ .venv\Scripts\activate
67
+ pip install "normschores[notebooks]"
68
+ normschores-notebooks my_run
69
+ ```
70
+
71
+ Then open the notebooks in `my_run` with `.venv\Scripts\python.exe` as the kernel (in VS Code:
72
+ *Select Kernel → Python Environments*; for a browser, also `pip install jupyterlab`) and run
73
+ `_ Run all notebooks.ipynb`, or the notebooks one at a time in numbered order. `normschores-notebooks`
74
+ refuses to overwrite notebooks already in the folder unless `--force` is given.
75
+
76
+ The model can also be used directly:
77
+
78
+ ```python
79
+ from normschores import ChormsClass
80
+
81
+ model = ChormsClass(name="baseline")
82
+ model.link_to_cpp() # compiles cppfuncs/model_cpp.cpp shipped with the package
83
+ ```
84
+
85
+ ## Development setup (repository)
86
+
87
+ In the repository the notebooks are edited and run in place in `src/normschores/notebooks/`. Their
88
+ results (`saved/`, `output/`) are kept next to them but are not included in the built package. The
89
+ paper reads the figures and tables from there (`\codefigs`/`\codetabs` in `_main.tex`).
90
+
91
+ Move to the `code` directory and run:
92
+
93
+ ### Option A — uv
94
+
95
+ ```bash
96
+ uv sync
97
+ ```
98
+
99
+ This creates `.venv`, installs `normschores` in editable mode (so changes in `src/` are picked up
100
+ directly) and the notebook tools (`ipykernel`, `papermill`) from the `dev` dependency group.
101
+
102
+ Activate the environment:
103
+
104
+ ```bash
105
+ # Windows
106
+ .venv\Scripts\activate
107
+
108
+ # Linux / macOS
109
+ source .venv/bin/activate
110
+ ```
111
+
112
+ For Jupyter notebooks in VS Code, the kernel is located at `.venv\Scripts\python.exe`.
113
+
114
+ ### Option B — pip + venv
115
+
116
+ ```bash
117
+ python -m venv .venv
118
+
119
+ # Windows
120
+ .venv\Scripts\activate
121
+ # Linux / macOS
122
+ source .venv/bin/activate
123
+
124
+ pip install -r requirements.txt
125
+ ```
126
+
127
+ ### Option C — Anaconda / conda
128
+
129
+ ```bash
130
+ conda env create -f environment.yml
131
+ conda activate normschores
132
+ ```
133
+
134
+ ---
135
+
136
+ ## Releasing
137
+
138
+ Builds use [uv](https://docs.astral.sh/uv/) (`uv build`, with the `uv_build` backend). Publishing
139
+ is done by the GitHub Actions workflow `.github/workflows/publish.yml` (in the repository root).
140
+
141
+ To publish a new version to PyPI:
142
+
143
+ ```bash
144
+ uv version --bump patch # or minor / major; updates pyproject.toml and uv.lock
145
+ git commit -am "Release v$(uv version --short)"
146
+ git tag "v$(uv version --short)"
147
+ git push && git push --tags
148
+ ```
149
+
150
+ Pushing a `v*` tag runs the workflow, which builds the package and uploads it to PyPI with trusted publishing (no API token stored in GitHub).
151
+
152
+ One-time setup on PyPI: under *Your projects → Publishing* add a pending trusted publisher with
153
+ owner `ThomasHJorgensen`, repository `NormsChores`, workflow `publish.yml` and environment `pypi`.
154
+ Also create an environment named `pypi` in the GitHub repository settings.
155
+
156
+ ## Appendix: Maintaining dependency files
157
+
158
+ ### Updating `requirements.txt`
159
+
160
+ `requirements.txt` is generated by uv from `pyproject.toml`. After adding or upgrading
161
+ packages in `pyproject.toml`, regenerate it with:
162
+
163
+ ```bash
164
+ uv lock
165
+ uv export --no-hashes -o requirements.txt
166
+ ```
@@ -0,0 +1,143 @@
1
+ # normschores
2
+
3
+ Code for the NormsChores project: a structural household model of gender norms and the division of
4
+ market work, chores and leisure, with simulated-minimum-distance estimation tools.
5
+
6
+ The Python package lives in `src/normschores/`:
7
+
8
+ | module | contents |
9
+ | --- | --- |
10
+ | `normschores.Chorms` | `ChormsClass`, the model (solved in C++, see `cppfuncs/`) |
11
+ | `normschores.estimate` | moments (`moments`), bootstrap covariance (`bootstrap_cov`), SMD estimator (`SMD`) |
12
+ | `normschores.exhibits` | figures and tables for the paper |
13
+ | `normschores.LocalEconModel` | vendored copy of [EconModel](https://github.com/NumEconCopenhagen/EconModel) used for the C++ linking |
14
+ | `normschores/notebooks/` | the notebooks that reproduce the paper (`0_DataMoments.ipynb`, `1_EstimateModel.ipynb`, ..., `_ Run all notebooks.ipynb`) |
15
+
16
+ ## Requirements
17
+
18
+ **Windows only.** The model is solved in C++ which is compiled on first use with Microsoft Visual
19
+ Studio (2019/2022 Community is found automatically; for other editions set `COMPILER_PATH` in the
20
+ notebooks, or pass `ChormsClass(..., compiler_path="<VS>/VC/Auxiliary/Build/")`). The compiled
21
+ `model_cpp.dll` is written to the current working directory. Python 3.12 or newer.
22
+
23
+ ## Running the notebooks from the published package
24
+
25
+ Create a fresh virtual environment, install the package with the `notebooks` extra (adds `ipykernel`
26
+ and `papermill`) and copy the notebooks to a working folder. The notebooks write their results
27
+ (`saved/`, `output/figures/`, `output/tables/`) relative to the folder they are run from, so always
28
+ run them from such a copy, never from inside the installed package.
29
+
30
+ With [uv](https://docs.astral.sh/uv/):
31
+
32
+ ```bash
33
+ uv venv --python 3.12 .venv
34
+ .venv\Scripts\activate
35
+ uv pip install "normschores[notebooks]"
36
+ normschores-notebooks my_run # copies the notebooks to .\my_run
37
+ ```
38
+
39
+ or with plain pip:
40
+
41
+ ```bash
42
+ py -3.12 -m venv .venv
43
+ .venv\Scripts\activate
44
+ pip install "normschores[notebooks]"
45
+ normschores-notebooks my_run
46
+ ```
47
+
48
+ Then open the notebooks in `my_run` with `.venv\Scripts\python.exe` as the kernel (in VS Code:
49
+ *Select Kernel → Python Environments*; for a browser, also `pip install jupyterlab`) and run
50
+ `_ Run all notebooks.ipynb`, or the notebooks one at a time in numbered order. `normschores-notebooks`
51
+ refuses to overwrite notebooks already in the folder unless `--force` is given.
52
+
53
+ The model can also be used directly:
54
+
55
+ ```python
56
+ from normschores import ChormsClass
57
+
58
+ model = ChormsClass(name="baseline")
59
+ model.link_to_cpp() # compiles cppfuncs/model_cpp.cpp shipped with the package
60
+ ```
61
+
62
+ ## Development setup (repository)
63
+
64
+ In the repository the notebooks are edited and run in place in `src/normschores/notebooks/`. Their
65
+ results (`saved/`, `output/`) are kept next to them but are not included in the built package. The
66
+ paper reads the figures and tables from there (`\codefigs`/`\codetabs` in `_main.tex`).
67
+
68
+ Move to the `code` directory and run:
69
+
70
+ ### Option A — uv
71
+
72
+ ```bash
73
+ uv sync
74
+ ```
75
+
76
+ This creates `.venv`, installs `normschores` in editable mode (so changes in `src/` are picked up
77
+ directly) and the notebook tools (`ipykernel`, `papermill`) from the `dev` dependency group.
78
+
79
+ Activate the environment:
80
+
81
+ ```bash
82
+ # Windows
83
+ .venv\Scripts\activate
84
+
85
+ # Linux / macOS
86
+ source .venv/bin/activate
87
+ ```
88
+
89
+ For Jupyter notebooks in VS Code, the kernel is located at `.venv\Scripts\python.exe`.
90
+
91
+ ### Option B — pip + venv
92
+
93
+ ```bash
94
+ python -m venv .venv
95
+
96
+ # Windows
97
+ .venv\Scripts\activate
98
+ # Linux / macOS
99
+ source .venv/bin/activate
100
+
101
+ pip install -r requirements.txt
102
+ ```
103
+
104
+ ### Option C — Anaconda / conda
105
+
106
+ ```bash
107
+ conda env create -f environment.yml
108
+ conda activate normschores
109
+ ```
110
+
111
+ ---
112
+
113
+ ## Releasing
114
+
115
+ Builds use [uv](https://docs.astral.sh/uv/) (`uv build`, with the `uv_build` backend). Publishing
116
+ is done by the GitHub Actions workflow `.github/workflows/publish.yml` (in the repository root).
117
+
118
+ To publish a new version to PyPI:
119
+
120
+ ```bash
121
+ uv version --bump patch # or minor / major; updates pyproject.toml and uv.lock
122
+ git commit -am "Release v$(uv version --short)"
123
+ git tag "v$(uv version --short)"
124
+ git push && git push --tags
125
+ ```
126
+
127
+ Pushing a `v*` tag runs the workflow, which builds the package and uploads it to PyPI with trusted publishing (no API token stored in GitHub).
128
+
129
+ One-time setup on PyPI: under *Your projects → Publishing* add a pending trusted publisher with
130
+ owner `ThomasHJorgensen`, repository `NormsChores`, workflow `publish.yml` and environment `pypi`.
131
+ Also create an environment named `pypi` in the GitHub repository settings.
132
+
133
+ ## Appendix: Maintaining dependency files
134
+
135
+ ### Updating `requirements.txt`
136
+
137
+ `requirements.txt` is generated by uv from `pyproject.toml`. After adding or upgrading
138
+ packages in `pyproject.toml`, regenerate it with:
139
+
140
+ ```bash
141
+ uv lock
142
+ uv export --no-hashes -o requirements.txt
143
+ ```
@@ -0,0 +1,68 @@
1
+ [project]
2
+ name = "normschores"
3
+ version = "0.1.0"
4
+ description = "Structural household model of gender norms and the division of market work, chores and leisure."
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ classifiers = [
8
+ "Programming Language :: Python :: 3",
9
+ "Programming Language :: C++",
10
+ "Operating System :: Microsoft :: Windows",
11
+ "Intended Audience :: Science/Research",
12
+ "Topic :: Scientific/Engineering",
13
+ ]
14
+ dependencies = [
15
+ "matplotlib>=3.11.1",
16
+ "numpy>=2.5.1",
17
+ "pandas>=3.0.5",
18
+ "polars>=1.44",
19
+ "pyfixest>=0.60",
20
+ "scipy>=1.18.0",
21
+ ]
22
+
23
+ [[project.authors]]
24
+ name = "Thomas H. Jørgensen"
25
+
26
+ [[project.authors]]
27
+ name = "Adam Hallengreen"
28
+
29
+ [project.urls]
30
+ Repository = "https://github.com/ThomasHJorgensen/NormsChores"
31
+
32
+ [project.optional-dependencies]
33
+ notebooks = [
34
+ "ipykernel>=7.3.0",
35
+ "papermill>=2.6.0",
36
+ ]
37
+
38
+ [project.scripts]
39
+ normschores-notebooks = "normschores._notebooks:main"
40
+
41
+ [build-system]
42
+ requires = ["uv_build>=0.11.8,<0.12"]
43
+ build-backend = "uv_build"
44
+
45
+ [tool.uv.build-backend]
46
+ source-exclude = [
47
+ "normschores/cppfuncs/nlopt-2.4.2-dll64.zip",
48
+ "normschores/cppfuncs/nlopt-2.4.2-dll64/matlab",
49
+ "*.obj",
50
+ "normschores/notebooks/saved",
51
+ "normschores/notebooks/output",
52
+ "normschores/notebooks/temp_notebooks",
53
+ "normschores/notebooks/*.dll",
54
+ ".ipynb_checkpoints",
55
+ ]
56
+ wheel-exclude = [
57
+ "normschores/cppfuncs/nlopt-2.4.2-dll64.zip",
58
+ "normschores/cppfuncs/nlopt-2.4.2-dll64/matlab",
59
+ "*.obj",
60
+ "normschores/notebooks/saved",
61
+ "normschores/notebooks/output",
62
+ "normschores/notebooks/temp_notebooks",
63
+ "normschores/notebooks/*.dll",
64
+ ".ipynb_checkpoints",
65
+ ]
66
+
67
+ [dependency-groups]
68
+ dev = ["normschores[notebooks]"]
@@ -0,0 +1,73 @@
1
+ [project]
2
+ name = "normschores"
3
+ version = "0.1.0"
4
+ description = "Structural household model of gender norms and the division of market work, chores and leisure."
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Thomas H. Jørgensen" },
8
+ { name = "Adam Hallengreen" },
9
+ ]
10
+ requires-python = ">=3.12"
11
+ classifiers = [
12
+ "Programming Language :: Python :: 3",
13
+ "Programming Language :: C++",
14
+ "Operating System :: Microsoft :: Windows",
15
+ "Intended Audience :: Science/Research",
16
+ "Topic :: Scientific/Engineering",
17
+ ]
18
+ dependencies = [
19
+ "matplotlib>=3.11.1",
20
+ "numpy>=2.5.1",
21
+ "pandas>=3.0.5",
22
+ "polars>=1.44",
23
+ "pyfixest>=0.60",
24
+ "scipy>=1.18.0",
25
+ ]
26
+
27
+ [project.urls]
28
+ Repository = "https://github.com/ThomasHJorgensen/NormsChores"
29
+
30
+ [project.optional-dependencies]
31
+ # for running the notebooks shipped with the package (see normschores-notebooks)
32
+ notebooks = [
33
+ "ipykernel>=7.3.0",
34
+ "papermill>=2.6.0",
35
+ ]
36
+
37
+ [project.scripts]
38
+ normschores-notebooks = "normschores._notebooks:main"
39
+
40
+ [build-system]
41
+ requires = ["uv_build>=0.11.8,<0.12"]
42
+ build-backend = "uv_build"
43
+
44
+ [tool.uv.build-backend]
45
+ # ship the C++ sources, the nlopt headers/dll/import library and the notebooks, but not the nlopt
46
+ # extras or any results
47
+ source-exclude = [
48
+ "normschores/cppfuncs/nlopt-2.4.2-dll64.zip",
49
+ "normschores/cppfuncs/nlopt-2.4.2-dll64/matlab",
50
+ "*.obj",
51
+ # results the notebooks write when run in place (the copies made by normschores-notebooks write their own)
52
+ "normschores/notebooks/saved",
53
+ "normschores/notebooks/output",
54
+ "normschores/notebooks/temp_notebooks",
55
+ "normschores/notebooks/*.dll",
56
+ ".ipynb_checkpoints",
57
+ ]
58
+ wheel-exclude = [
59
+ "normschores/cppfuncs/nlopt-2.4.2-dll64.zip",
60
+ "normschores/cppfuncs/nlopt-2.4.2-dll64/matlab",
61
+ "*.obj",
62
+ # results the notebooks write when run in place (the copies made by normschores-notebooks write their own)
63
+ "normschores/notebooks/saved",
64
+ "normschores/notebooks/output",
65
+ "normschores/notebooks/temp_notebooks",
66
+ "normschores/notebooks/*.dll",
67
+ ".ipynb_checkpoints",
68
+ ]
69
+
70
+ [dependency-groups]
71
+ dev = [
72
+ "normschores[notebooks]",
73
+ ]