Skip to content

Commit 437f579

Browse files
committed
Small changes to docs and tests for percentchange
1 parent 1237da9 commit 437f579

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

census_data_aggregator/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,14 +370,16 @@ def approximate_percentchange(pair_old, pair_new):
370370
(61393366, 202289)
371371
372372
Examples:
373+
The change of percentage of single women in suburban Virginia,
374+
taken from the bureau's official example as well as data `gathered elsewhere`_.
373375
374376
>>> approximate_percentchange((135173, 3860), (139301, 4047))
375377
(3.0538643072211165, 4.198069852261231)
376378
377-
2017 value from: https://www.fairfaxcounty.gov/demographics/sites/demographics/files/assets/acs/acs2017.pdf
378-
379379
... _official guidelines:
380380
https://www.documentcloud.org/documents/6177941-Acs-General-Handbook-2018-ch08.html#document/p8
381+
... _gathered elsewhere:
382+
https://www.fairfaxcounty.gov/demographics/sites/demographics/files/assets/acs/acs2017.pdf
381383
"""
382384
# Pull out the values
383385
estimate_old, moe_old = pair_old

test.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import doctest
44
import unittest
55
import census_data_aggregator
6-
from census_data_aggregator.exceptions import DesignFactorWarning, DataError
6+
from census_data_aggregator.exceptions import (
7+
DesignFactorWarning,
8+
DataError
9+
)
710

811

912
class CensusErrorAnalyzerTest(unittest.TestCase):
@@ -85,6 +88,14 @@ def test_median(self):
8588
]
8689
census_data_aggregator.approximate_median(top_median, design_factor=1.5)
8790

91+
def test_percentchange(self):
92+
estimate, moe = census_data_aggregator.approximate_percentchange(
93+
(135173, 3860),
94+
(139301, 4047)
95+
)
96+
self.assertAlmostEqual(estimate, 3.0538643072211165)
97+
self.assertAlmostEqual(moe, 4.198069852261231)
98+
8899
def test_exception(self):
89100
DesignFactorWarning().__str__()
90101

0 commit comments

Comments
 (0)