11from utils import load_csv_columns , list_key_set , list_key_values
22
33def test_sunlight ():
4- print "\t new, old"
4+ print ( "\t new, old" )
55
66 new_data = load_csv_columns ('zccd.csv' )
77 old_data = load_csv_columns ('raw/old_sunlight_districts.csv' )
8- print "length" , len (new_data ), len (old_data )
9- print
8+ print ( "length" , len (new_data ), len (old_data ) )
9+ print ()
1010
1111 new_states = list_key_set (new_data , 'state_abbr' )
1212 old_states = list_key_set (old_data , 'state' )
13- print "states" , len (new_states ), len (old_states )
14- assert len (old_states .difference (new_states )) == 0
15- assert len (new_states .difference (old_states )) == 0
16- print
13+ print ("states" , len (new_states ), len (old_states ))
14+ print ()
1715
1816 new_zctas = list_key_set (new_data , 'zcta' )
1917 old_zctas = list_key_set (old_data , 'zipcode' )
20- print "ZCTAs" , len (new_zctas ), len (old_zctas )
18+ print ( "ZCTAs" , len (new_zctas ), len (old_zctas ) )
2119 # we should not be missing any old zctas
22- assert len ( old_zctas .difference (new_zctas )) == 0
23- print "added" , new_zctas .difference (old_zctas )
24- print
20+ print ( "missing" , old_zctas .difference (new_zctas ))
21+ print ( "added" , new_zctas .difference (old_zctas ) )
22+ print ()
2523
2624 new_zcta_list = list_key_values (new_data , 'zcta' )
2725 old_zcta_list = list_key_values (old_data , 'zipcode' )
@@ -34,37 +32,36 @@ def test_sunlight():
3432 cds_changed += 1
3533 new_state = list_key_values (l ,'state_abbr' )
3634 old_state = list_key_values (old_zcta_list [n ], 'state' )
37- print "%s was %s-%s now %s-%s" % (n , ',' .join (old_state ), ',' .join (old_cd_set ), ',' .join (new_state ), ',' .join (new_cd_set ))
35+ print ( "%s was %s-%s now %s-%s" % (n , ',' .join (old_state ), ',' .join (old_cd_set ), ',' .join (new_state ), ',' .join (new_cd_set ) ))
3836 states_changed .update (new_state .keys ())
3937 states_changed .update (old_state .keys ())
4038
41- print "CDs changed" , cds_changed
42- print "from states" , states_changed
43- print
39+ print ( "CDs changed" , cds_changed )
40+ print ( "from states" , states_changed )
41+ print ()
4442
4543def test_hud ():
46- print "\t us, hud"
44+ print ( "\t us, hud" )
4745
4846 our_data = load_csv_columns ('zccd.csv' )
4947 hud_data = load_csv_columns ('zccd_hud.csv' )
50- print "length" , len (our_data ), len (hud_data )
51- print
48+ print ( "length" , len (our_data ), len (hud_data ) )
49+ print ()
5250
5351 our_states = list_key_set (our_data , 'state_abbr' )
5452 hud_states = list_key_set (hud_data , 'state_abbr' )
55- print "states" , len (our_states ), len (hud_states )
56- assert len (hud_states .difference (our_states )) == 0
57- print "we added" , our_states .difference (hud_states )
58- print
53+ print ("states" , len (our_states ), len (hud_states ))
54+ print ("we missed" , list (hud_states .difference (our_states )))
55+ print ()
5956
6057 our_zctas = list_key_set (our_data , 'zcta' )
6158 hud_zips = list_key_set (hud_data , 'zip' )
62- print "ZCTAs" , len (our_zctas ), len (hud_zips )
59+ print ( "ZCTAs" , len (our_zctas ), len (hud_zips ) )
6360 # we should not be missing any hud zctas
64- print "we added" , len (our_zctas .difference (hud_zips ))
65- print "missing" , len (hud_zips .difference (our_zctas ))
66- print sorted (list (hud_zips .difference (our_zctas )))
67- print
61+ print ( "we added" , len (our_zctas .difference (hud_zips ) ))
62+ print ( "missing" , len (hud_zips .difference (our_zctas ) ))
63+ print ( sorted (list (hud_zips .difference (our_zctas ) )))
64+ print ()
6865
6966 our_zcta_list = list_key_values (our_data , 'zcta' )
7067 hud_zip_list = list_key_values (hud_data , 'zip' )
@@ -81,9 +78,10 @@ def test_hud():
8178 states_changed .update (our_state .keys ())
8279 states_changed .update (hud_state .keys ())
8380
84- print "CDs differing" , cds_changed
85- print "from states" , states_changed
86- print
81+ print ( "CDs differing" , cds_changed )
82+ print ( "from states" , states_changed )
83+ print ()
8784
8885if __name__ == "__main__" :
86+ test_sunlight ()
8987 test_hud ()
0 commit comments