Skip to content

Commit 5e62f7d

Browse files
committed
updates
1 parent 1a7604e commit 5e62f7d

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

census_area/__init__.py

+21-13
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def emit(self, record):
2323

2424

2525
class GeoClient(census.core.Client):
26-
@supported_years(2015, 2014, 2013, 2012, 2011, 2010, 2000)
27-
def geo_tract(self, fields, geojson_geometry, year=None):
26+
@supported_years(2015, 2014, 2013, 2012, 2011, 2010, 2000, 1990)
27+
def geo_tract(self, fields, geojson_geometry, year=None, **kwargs):
2828
if year is None:
2929
year = self.default_year
3030

@@ -39,7 +39,7 @@ def geo_tract(self, fields, geojson_geometry, year=None):
3939
tract_id = tract['properties']['TRACT']
4040
result = self.get(fields,
4141
{'for': 'tract:{}'.format(tract_id),
42-
'in' : within}, year)
42+
'in' : within}, year, **kwargs)
4343

4444
if result:
4545
result, = result
@@ -49,7 +49,7 @@ def geo_tract(self, fields, geojson_geometry, year=None):
4949
yield tract, result
5050

5151
@supported_years(2015, 2014, 2013, 2012, 2011, 2010, 2000)
52-
def geo_blockgroup(self, fields, geojson_geometry, year=None):
52+
def geo_blockgroup(self, fields, geojson_geometry, year=None, **kwargs):
5353
if year is None:
5454
year = self.default_year
5555

@@ -66,7 +66,7 @@ def geo_blockgroup(self, fields, geojson_geometry, year=None):
6666

6767
result = self.get(fields,
6868
{'for': 'block group:{}'.format(block_group_id),
69-
'in' : within}, year)
69+
'in' : within}, year, **kwargs)
7070

7171
if result:
7272
result, = result
@@ -76,7 +76,7 @@ def geo_blockgroup(self, fields, geojson_geometry, year=None):
7676
yield block_group, result
7777

7878

79-
def _state_place_area(self, method, fields, state, place, year=None, return_geometry=False):
79+
def _state_place_area(self, method, fields, state, place, year=None, return_geometry=False, **kwargs):
8080
if year is None:
8181
year = self.default_year
8282

@@ -89,7 +89,7 @@ def _state_place_area(self, method, fields, state, place, year=None, return_geom
8989
logging.info(place['properties']['NAME'])
9090
place_geojson = place['geometry']
9191

92-
areas = method(fields, place_geojson, year)
92+
areas = method(fields, place_geojson, year, **kwargs)
9393

9494
features = []
9595
for i, (feature, result) in enumerate(areas):
@@ -106,15 +106,23 @@ def _state_place_area(self, method, fields, state, place, year=None, return_geom
106106
else:
107107
return features
108108

109-
def geo(self, fields, geojson_geometry, year=None, resolution='tract', ignore_missing = False):
109+
def geo(self, fields, geojson_geometry, year=None, resolution='tract', ignore_missing = False, **kwargs):
110110
if year is None:
111111
year = self.default_year
112-
112+
113113
fields = census.core.list_or_str(fields)
114114

115-
for field in fields:
116-
if self._field_type(field, year) is not int:
117-
raise ValueError('{} is not a variable that can be aggregated your geography'.format(field))
115+
as_acs = kwargs.get('as_acs', False)
116+
if as_acs:
117+
acs_fields = self._cross(fields)
118+
for field in acs_fields:
119+
if self._field_type(field, year) is not int:
120+
raise ValueError('{} is not a variable that can be aggregated your geography'.format(field))
121+
else:
122+
for field in fields:
123+
if self._field_type(field, year) is not int:
124+
raise ValueError('{} is not a variable that can be aggregated your geography'.format(field))
125+
118126

119127
resolutions = {'tract': self.geo_tract,
120128
'blockgroup': self.geo_blockgroup}
@@ -124,7 +132,7 @@ def geo(self, fields, geojson_geometry, year=None, resolution='tract', ignore_mi
124132
except KeyError:
125133
raise ValueError('{} is not a valid resolution. Choose one of {}'.format(resolution, resolution.keys()))
126134

127-
features = geo_units(fields, geojson_geometry, year=year)
135+
features = geo_units(fields, geojson_geometry, year=year, **kwargs)
128136

129137
return self._aggregate(fields, features, year, ignore_missing)
130138

0 commit comments

Comments
 (0)