Skip to content

Commit

Permalink
Merge pull request #105 from ronnie-llamado/bug/fix-test-endpoints-te…
Browse files Browse the repository at this point in the history
…st-acs5

Deprecate `zipcode` for `state_zipcode` in `acs5`
  • Loading branch information
fgregg authored Oct 13, 2021
2 parents 077c158 + fc5b186 commit 3f79bf9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ ACS5 Geographies
* state_legislative_district_upper(fields, state_fips, legislative_district)
* state_legislative_district_lower(fields, state_fips, legislative_district)
* us(fields)
* zipcode(fields, zip5)
* state_zipcode(fields, state_fips, zip5)

ACS1 Geographies
----------------
Expand Down
12 changes: 12 additions & 0 deletions census/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,20 @@ def state_county_blockgroup(self, fields, state_fips, county_fips,

@supported_years(2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011)
def zipcode(self, fields, zcta, **kwargs):
warnings.warn(
"zipcode has been deprecated; use state_zipcode instead",
DeprecationWarning
)

state_fips = kwargs.pop('state_fips')

return self.state_zipcode(fields, state_fips, zcta, **kwargs)

@supported_years(2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011)
def state_zipcode(self, fields, state_fips, zcta, **kwargs):
return self.get(fields, geo={
'for': 'zip code tabulation area:{}'.format(zcta),
'in': 'state:{}'.format(state_fips),
}, **kwargs)


Expand Down
2 changes: 1 addition & 1 deletion census/tests/test_census.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def test_acs5(self):
'State Senate District 7 (2018), Maryland'),
('state_legislative_district_lower',
'State Legislative District 7 (2018), Maryland'),
('zipcode', 'ZCTA5 20877'),
('state_zipcode', 'ZCTA5 20877'),
)

self.check_endpoints('acs5', tests)
Expand Down

0 comments on commit 3f79bf9

Please sign in to comment.