Fix county subdivision part lookup and chunk long ucgid requests - #6
Merged
Merged
Conversation
The pseudo lookup added in 0.6.3 read GeoIDFQ attributes by API name, which fails for "county subdivision" (cousub), and gave every scope county every county subdivision. Pair each parent with the children it shares fields with. Also request plain ucgid lists in chunks of 100: the 498 place/remainder parts (070) in region15 in one URL were dropped by the Census API. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CensusAPI(Endpoint('dec/dhc', 2020), 'region15', sumlevel=SumLevel('070'), ...)(county subdivision place/remainder parts) failed in two ways:getattr(GeoIDFQ, geo)using the API's name. That fails forcounty subdivision, whichGeoIDFQcallscousub(AttributeError). It also gave every scope county the same list of children. That's right for places, which don't nest in counties, but for070it would pair every county with every county subdivision.070that's 498 GEOIDs (about 12 KB), and the Census API drops the connection.Change
geos.py: useSumLevel(geo).parts[-1]as theGeoIDFQattribute, and give each parent row only the children that match it on shared fields (countyfor county subdivisions; onlystatefor places).api.py:_fetch_variablessends plain ucgid lists in chunks of 100.pseudo()predicates are unchanged.Note:
dec/pldoesn't publish070in any year.dec/dhc(2020) anddec/sf1(2010, 2000) do.Testing
tests/test_geos_hierarchical.py(each county is paired with its own subdivisions), and 2 intests/test_api.py(a long ucgid list is chunked; a pseudo query is not). All three failed before the change. Full suite: 343 passed.070:070geographies each year.dec/pltotal (263 of 264 match exactly in 2020). The exceptions are parts of places that no longer exist.0.6.4) andreference/dev_notes.mdare updated.🤖 Generated with Claude Code