Skip to content

Commit 58549ab

Browse files
author
virgesmith
committed
Fix #38
1 parent 46bb42c commit 58549ab

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def read_reqs():
1212

1313
setuptools.setup(
1414
name='ukpopulation',
15-
version="1.2.0",
15+
version="1.2.1",
1616
description='Download, cache, collate, filter, manipulate and extrapolate UK population and household estimates/projections',
1717
long_description=readme(),
1818
long_description_content_type="text/markdown",

ukpopulation/customsnppdata.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,18 @@ def __init__(self, name, cache_dir=utils.default_cache_dir()):
4343
filename = _custom_snpp_filename(name, self.cache_dir)
4444
self.data = pd.read_csv(filename)
4545

46-
def min_year(self):
46+
def min_year(self, _=None):
4747
"""
4848
Returns the first year in the projection
49+
(usused argument to make interface consistent with SNPPData)
4950
"""
5051
# convert to country if necessary
5152
return min(self.data.PROJECTED_YEAR_NAME.unique())
5253

53-
def max_year(self):
54+
def max_year(self, _=None):
5455
"""
5556
Returns the final year in the projection
57+
(usused argument to make interface consistent with SNPPData)
5658
"""
5759
return max(self.data.PROJECTED_YEAR_NAME.unique())
5860

@@ -153,7 +155,7 @@ def create_variant(self, variant_name, npp, geog_codes, year_range):
153155
# split out any years prior to the NPP data (currently SNPP is 2014 based but NPP is 2016)
154156
(pre_range, in_range) = utils.split_range(year_range, npp.min_year() - 1)
155157
# for any years prior to NPP we just use the SNPP data as-is (i.e. "ppp")
156-
pre_data = self.filter(geog_code, pre_range)
158+
pre_data = self.filter(geog_code, pre_range) if pre_range else pd.DataFrame()
157159
if len(pre_data) > 0:
158160
print("WARNING: variant {} not applied for years {} that predate the NPP data".format(variant_name, pre_range))
159161

ukpopulation/nppdata.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def detail(self, variant_name, geog, years=None, ages=range(0,91), genders=[1,2]
9999
genders = [genders]
100100

101101
if not variant_name in NPPData.VARIANTS:
102-
raise RuntimeError("invalid variant name: " + variant_name)
102+
raise RuntimeError("invalid NPP variant name: " + variant_name)
103103
# make years a valid range (this *silently* removes invalid years)
104104
years = utils.trim_range(years, self.min_year(), self.max_year())
105105

0 commit comments

Comments
 (0)