File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 33import doctest
44import unittest
55import 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
912class 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
You can’t perform that action at this time.
0 commit comments