normschores
Code for the NormsChores project: a structural household model of gender norms and the division of market work, chores and leisure, with simulated-minimum-distance estimation tools.
The Python package lives in src/normschores/:
| module | contents |
|---|---|
normschores.Chorms |
ChormsClass, the model (solved in C++, see cppfuncs/) |
normschores.estimate |
moments (moments), bootstrap covariance (bootstrap_cov), SMD estimator (SMD) |
normschores.exhibits |
figures and tables for the paper |
normschores.LocalEconModel |
vendored copy of EconModel used for the C++ linking |
normschores/notebooks/ |
the notebooks that reproduce the paper (0_DataMoments.ipynb, 1_EstimateModel.ipynb, ..., _ Run all notebooks.ipynb) |
Requirements
Windows only. The model is solved in C++ which is compiled on first use with Microsoft Visual
Studio (2019/2022 Community is found automatically; for other editions set COMPILER_PATH in the
notebooks, or pass ChormsClass(..., compiler_path="<VS>/VC/Auxiliary/Build/")). The compiled
model_cpp.dll is written to the current working directory. Python 3.12 or newer.
Running the notebooks from the published package
Create a fresh virtual environment, install the package with the notebooks extra (adds ipykernel
and papermill) and copy the model code and notebooks to a working folder with normschores-copy.
The notebooks import the model code from the folder above them (from Chorms import *,
from estimate.moments import ..., import exhibits), not from the installed normschores. A copy
is therefore self-contained: edits to its Chorms.py, estimate/, exhibits.py and cppfuncs/*.cpp
are what its notebooks use. The notebooks write their results (saved/, output/figures/,
output/tables/, model_cpp.dll) into the copy's notebooks/ folder.
With uv:
uv venv --python 3.12 .venv
.venv\Scripts\activate
uv pip install "normschores[notebooks]"
normschores-copy my_run # copies the code and notebooks to .\my_run
or with plain pip:
py -3.12 -m venv .venv
.venv\Scripts\activate
pip install "normschores[notebooks]"
normschores-copy my_run
Then open the notebooks in my_run\notebooks with .venv\Scripts\python.exe as the kernel (in VS
Code: Select Kernel → Python Environments; for a browser, also pip install jupyterlab) and run
_ Run all notebooks.ipynb, or the notebooks one at a time in numbered order. normschores-copy
refuses to write into a folder that is not empty unless --force is given.
After editing C++ files, set DO_COMPILE = True (and restart the kernel) so model_cpp.dll is
rebuilt; otherwise an existing dll in the notebook folder is reused. Python edits are picked up by the
notebooks' %autoreload, or after a kernel restart.
The model can also be used directly:
from normschores import ChormsClass
model = ChormsClass(name="baseline")
model.link_to_cpp() # compiles cppfuncs/model_cpp.cpp shipped with the package
Development setup (repository)
In the repository the notebooks are edited and run in place in src/normschores/notebooks/. Their
results (saved/, output/) are kept next to them but are not included in the built package. The
paper reads the figures and tables from there (\codefigs/\codetabs in _main.tex).
Move to the code directory and run:
Option A — uv
uv sync
This creates .venv, installs normschores in editable mode (so changes in src/ are picked up
directly) and the notebook tools (ipykernel, papermill) from the dev dependency group.
Activate the environment:
# Windows
.venv\Scripts\activate
# Linux / macOS
source .venv/bin/activate
For Jupyter notebooks in VS Code, the kernel is located at .venv\Scripts\python.exe.
Option B — pip + venv
python -m venv .venv
# Windows
.venv\Scripts\activate
# Linux / macOS
source .venv/bin/activate
pip install -r requirements.txt
Option C — Anaconda / conda
conda env create -f environment.yml
conda activate normschores
Releasing
Builds use uv (uv build, with the uv_build backend). Publishing
is done by the GitHub Actions workflow .github/workflows/publish.yml (in the repository root).
To publish a new version to PyPI:
uv version --bump patch # or minor / major; updates pyproject.toml and uv.lock
git commit -am "Release v$(uv version --short)"
git tag "v$(uv version --short)"
git push && git push --tags
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).
One-time setup on PyPI: under Your projects → Publishing add a pending trusted publisher with
owner ThomasHJorgensen, repository NormsChores, workflow publish.yml and environment pypi.
Also create an environment named pypi in the GitHub repository settings.
Appendix: Maintaining dependency files
Updating requirements.txt
requirements.txt is generated by uv from pyproject.toml. After adding or upgrading
packages in pyproject.toml, regenerate it with:
uv lock
uv export --no-hashes -o requirements.txt
Metadata
Release files for normschores 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| normschores-0.2.0.tar.gz | 2.4 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| normschores-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.8 MB
Release files / normschores-0.2.0.tar.gz
| Download URL | normschores-0.2.0.tar.gz |
|---|---|
| Size | 2.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
78f355a473df26be42548b4ec1bd98fd28641a5841e73b6d7cdb8364f4c385f7
|
|
BLAKE2b-256 checksum How to use checksums |
647a67737e77bd443e61a71d650f6860edda851c41cace0df7cb8e1ff348b15d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / normschores-0.2.0-py3-none-any.whl
| Download URL | normschores-0.2.0-py3-none-any.whl |
|---|---|
| Size | 2.4 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f9a79377bb9f036ca5f942c2b11b6f865247857c4c098ca486076ad73bf09fdf
|
|
BLAKE2b-256 checksum How to use checksums |
5aa66b516af3d8c5e74d881760d27d2b38ea1d98d42e38b722df92b1f7fafba8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|