Commit 29fc538
Add Phase 3: estimates, flows, FIPS lookups, and caching integration (#297)
* Add Phase 3: estimates, flows, variable caching, FIPS lookups, and API caching
- Create pypums/estimates.py with get_estimates() for Population Estimates Program data
- Create pypums/flows.py with get_flows() for ACS Migration Flows data
- Enhance load_variables() with persistent disk caching via CensusCache
- Add lookup_fips() and lookup_name() to pypums/datasets/fips.py
- Wire cache_table=True option into get_acs(), get_decennial(), get_pums()
- Export get_estimates, get_flows, lookup_fips, lookup_name from package
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix review issues: cache key collisions, pickle→parquet, input validation
- Fix cache key collisions: include output, moe_level, summary_var,
pop_group, rep_weights, recode, variables_filter, puma in cache keys
- Switch cache.py from pickle to parquet to eliminate arbitrary code
execution risk from tampered cache files
- Add pyarrow dependency (required for parquet serialization)
- Validate product parameter in get_estimates() — raise ValueError for
unknown products instead of silent fallback
- Validate geography parameter in get_flows() against allowed values
- Add cache_table parameter to get_estimates() and get_flows() for
consistent API surface
- Document unimplemented parameters (time_series, breakdown_labels,
output, moe_level) in docstrings
- Fix double _get_persistent_cache() instantiation in variables.py
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix cache_table to read from cache before API call in estimates/flows
The cache_table parameter was write-only — it stored results but never
checked for cached data before making API calls. Also adds variables,
breakdown, and year to cache keys to prevent collisions.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Add pre-commit hooks with Ruff linting and formatting
Set up .pre-commit-config.yaml with ruff-check, ruff-format, and
standard pre-commit hooks (trailing whitespace, end-of-file, yaml/toml
checks). Fix all lint errors across the codebase: line length, import
ordering, formatting, zip() strict parameter, and trailing whitespace.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Reuse single CensusCache instance per cached call
Instantiate CensusCache once before the cache read check and reuse the
same instance for the write, instead of creating two separate instances.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 0d3500e commit 29fc538
File tree
33 files changed
+694
-105
lines changed- .github
- workflows
- docs
- about
- css
- reference
- user-guide
- pypums
- datasets
- tests
33 files changed
+694
-105
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
0 commit comments