PyTools
py_tools is a research-oriented Python toolkit for numerical economics, time series, estimation, and dataset loading utilities.
Installation
Install from PyPI:
pip install dgreenwald-py-tools
Or clone the repository and install in editable mode:
pip install -e .
Optional extras:
pip install "dgreenwald-py-tools[ml]" # scikit-learn, patsy
pip install "dgreenwald-py-tools[datasets]" # pandas-datareader, python-dotenv
pip install "dgreenwald-py-tools[scraping]" # requests, beautifulsoup4, lxml
pip install "dgreenwald-py-tools[nlp]" # nltk
pip install "dgreenwald-py-tools[mpi]" # mpi4py
pip install "dgreenwald-py-tools[dev]" # pytest, ruff
If you use dataset loaders, set:
export PY_TOOLS_DATA_DIR=/path/to/data
Or create a .env file in the repository root (or a parent directory):
PY_TOOLS_DATA_DIR=/path/to/data
Slurm jobs
py_tools.cluster renders typed single-job and array definitions and can submit the resulting
scripts with sbatch --parsable:
from py_tools.cluster import (
SLURM_ARRAY_TASK_ID,
SlurmArray,
SlurmJob,
SlurmResources,
submit_slurm,
write_slurm_script,
)
job = SlurmJob(
name="analysis",
command=("python", "worker.py", "--index", SLURM_ARRAY_TASK_ID),
workdir="/cluster/project",
log_dir="/cluster/project/output/slurm",
resources=SlurmResources(time="04:00:00", memory="16G", account="research"),
activate="/cluster/venv/bin/activate",
array=SlurmArray(task_count=20, max_concurrent=4),
)
script = write_slurm_script(job, "/cluster/project/output/slurm/jobs.slurm")
submission = submit_slurm(script)
print(submission.job_id)
py_tools.datasets will load .env automatically when python-dotenv is installed
(included in the datasets extra).
Quick Start
from py_tools import data, time_series, state_space
# Example: call a utility function from a core module
# (see module docstrings/source for full APIs)
You can also import dataset loaders through:
from py_tools import datasets
available = datasets.list_datasets()
df = datasets.load_dataset("fred", codes=["UNRATE"])
Module Overview
| Import path | Contents |
|---|---|
py_tools.time_series |
Kalman filter, state-space models, VAR/BVAR, HMMs |
py_tools.econometrics |
NLS/GMM, bootstrap, local projections, high-dimensional FE |
py_tools.bayesian |
MCMC sampling, prior distributions |
py_tools.numerical |
Root-finding, Chebyshev approximation |
py_tools.datasets |
Loaders for ~38 economic data sources |
py_tools.data |
Data manipulation, aggregation, matching |
py_tools.econ |
Discrete choice, yield curves, AIM solver |
py_tools.plot |
Plotting utilities |
py_tools.config |
Named model specification registry |
py_tools.scraping |
HTML scraping and text utilities |
py_tools.compute |
MPI array distribution |
Development
pip install -e ".[dev]"
python -m pytest # run tests
ruff check . # lint
Contributing
- Keep changes focused and commit one logical change at a time.
- Follow repository coding and workflow guidelines in
AGENTS.md. - Prefer adding deterministic tests in
tests/for new behavior.
License
MIT — see LICENSE.
Metadata
Release files for dgreenwald-py-tools 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dgreenwald_py_tools-0.2.5.tar.gz | 315.3 kB | Without provenance | Details for dgreenwald_py_tools-0.2.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dgreenwald_py_tools-0.2.5-py3-none-any.whl | Python 3 | none | any | Details for dgreenwald_py_tools-0.2.5-py3-none-any.whl |
Total release size: 618.5 kB
Release files / dgreenwald_py_tools-0.2.5.tar.gz
| Download URL | dgreenwald_py_tools-0.2.5.tar.gz |
|---|---|
| Size | 315.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
527042b2762cd2918d7a865a44a893d09760d1108cd88738465760e5f4cbb2db
|
|
BLAKE2b-256 checksum How to use checksums |
e2de81d2dbe1caeaee9a3ac643ef0615a0e142e62f62036197c1d2fa4df130ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / dgreenwald_py_tools-0.2.5-py3-none-any.whl
| Download URL | dgreenwald_py_tools-0.2.5-py3-none-any.whl |
|---|---|
| Size | 303.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
80c50d1e7c16ceb403fbdd4f64c9b65f4d983b9c37a0a68d383ebb03c7334cae
|
|
BLAKE2b-256 checksum How to use checksums |
8b18b63e7fa669a9961171440b7931b6985013530a64780ec41a3f97b47a49e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Security for dgreenwald-py-tools 0.2.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.