|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +Project-level context for Claude Code sessions working on PyPUMS. |
| 4 | + |
| 5 | +## Project overview |
| 6 | + |
| 7 | +PyPUMS is a Python interface to the US Census Bureau API. It provides functions for |
| 8 | +ACS, Decennial Census, PUMS microdata, population estimates, and migration flows. |
| 9 | +The package returns pandas DataFrames (or GeoDataFrames when `geometry=True`). |
| 10 | + |
| 11 | +- **Package source:** `pypums/` |
| 12 | +- **Tests:** `tests/` |
| 13 | +- **Docs:** `docs/` (MkDocs Material, hosted on ReadTheDocs) |
| 14 | +- **CLI:** `pypums/cli.py` (Typer) |
| 15 | + |
| 16 | +## Common commands |
| 17 | + |
| 18 | +```bash |
| 19 | +# Run tests (uses doctest + pytest) |
| 20 | +uv run pytest |
| 21 | + |
| 22 | +# Run a specific test file |
| 23 | +uv run pytest tests/test_get_acs.py |
| 24 | + |
| 25 | +# Lint and format |
| 26 | +uv run ruff check --fix . |
| 27 | +uv run ruff format . |
| 28 | + |
| 29 | +# Build docs locally |
| 30 | +uv run mkdocs build --strict |
| 31 | + |
| 32 | +# Serve docs locally (live reload) |
| 33 | +uv run mkdocs serve |
| 34 | +``` |
| 35 | + |
| 36 | +## Dependencies and lockfile |
| 37 | + |
| 38 | +This project uses **uv** for dependency management. |
| 39 | + |
| 40 | +**Important:** When you add or change dependencies in `pyproject.toml`, you **must** |
| 41 | +run `uv lock` and commit the updated `uv.lock`. ReadTheDocs uses |
| 42 | +`uv sync --frozen --extra docs` which requires the lockfile to be in sync with |
| 43 | +`pyproject.toml`. Forgetting to update `uv.lock` will cause the docs build to fail |
| 44 | +on CI. |
| 45 | + |
| 46 | +Optional dependency groups: |
| 47 | +- `spatial` — geopandas (for `geometry=True` support) |
| 48 | +- `test` — pytest |
| 49 | +- `docs` — mkdocs-material, mkdocstrings, mkdocs-charts-plugin, altair, etc. |
| 50 | + |
| 51 | +## Code style |
| 52 | + |
| 53 | +- **Linter/formatter:** Ruff (config in `pyproject.toml`) |
| 54 | +- **Target:** Python 3.10+ |
| 55 | +- **Pre-commit hooks:** trailing whitespace, end-of-file fixer, check-yaml, check-toml, |
| 56 | + ruff-check, ruff-format |
| 57 | + |
| 58 | +## Docs |
| 59 | + |
| 60 | +The documentation uses **MkDocs Material** with these notable plugins/extensions: |
| 61 | + |
| 62 | +- `mkdocs-charts-plugin` with `pymdownx.superfences` custom fences for rendering |
| 63 | + **Vega-Lite** charts inline. Use ` ```vegalite ` fenced code blocks with a JSON |
| 64 | + Vega-Lite spec to render interactive charts directly in the docs. |
| 65 | +- `mkdocstrings[python]` for API reference (numpy-style docstrings). |
| 66 | +- `mkdocs-typer` for CLI reference auto-generation. |
| 67 | +- Visualizations use **Altair** (not matplotlib). Code examples should use Altair, and |
| 68 | + rendered previews use Vega-Lite JSON specs in `vegalite` fenced blocks. |
| 69 | + |
| 70 | +Rendered Vega-Lite charts in docs should: |
| 71 | +- Use inline `"values"` data (not live API calls) so they render without a backend. |
| 72 | +- Include all 50 states + DC for choropleth maps. |
| 73 | +- Be wrapped in `!!! example "Interactive preview"` admonitions when the rendered chart |
| 74 | + shows a different geographic scale than the code example (e.g., state-level preview |
| 75 | + for a tract-level code example). |
| 76 | + |
| 77 | +## CI pipeline |
| 78 | + |
| 79 | +- **GitHub Actions:** lint (ruff), tests (Python 3.10-3.13) |
| 80 | +- **ReadTheDocs:** builds docs from `.readthedocs.yaml` using `uv sync --frozen --extra docs` |
| 81 | +- **Pre-commit hooks:** run on every commit (trailing whitespace, ruff, etc.) |
| 82 | + |
| 83 | +## Test markers |
| 84 | + |
| 85 | +``` |
| 86 | +phase0 — Foundation (API infra, geography, FIPS, cache) |
| 87 | +phase1 — Core data functions (get_acs, get_decennial, load_variables) |
| 88 | +phase2 — MOE, spatial, enhanced PUMS |
| 89 | +phase3 — Estimates, flows, survey |
| 90 | +integration — Requires real Census API key and network |
| 91 | +spatial — Requires geopandas |
| 92 | +``` |
0 commit comments