datadesk / python-elections

A Python wrapper for the Associated Press' U.S. election data service.
python-elections.rtfd.org
176 stars 46 forks source link

Presidential Race object from topofticket has farked reporting units #60

Closed palewire closed 12 years ago

palewire commented 12 years ago

Looks like the oddball areas are overriding the states or something. Here's what I seein the race._reporting_units attribute right now.


{'Albany51001': <ReportingUnit: Albany>,
 'Big Horn51002': <ReportingUnit: Big Horn>,
 'Campbell51003': <ReportingUnit: Campbell>,
 'Carbon51004': <ReportingUnit: Carbon>,
 'Converse51005': <ReportingUnit: Converse>,
 'Crook51006': <ReportingUnit: Crook>,
 'District of Columbia1': <ReportingUnit: District of Columbia (state)>,
 'District of Columbia9001': <ReportingUnit: District of Columbia>,
 'Fremont51007': <ReportingUnit: Fremont>,
 'Goshen51008': <ReportingUnit: Goshen>,
 'Hot Springs51009': <ReportingUnit: Hot Springs>,
 'Johnson51010': <ReportingUnit: Johnson>,
 'Laramie51011': <ReportingUnit: Laramie>,
 'Lincoln51012': <ReportingUnit: Lincoln>,
 'Natrona51013': <ReportingUnit: Natrona>,
 'Niobrara51014': <ReportingUnit: Niobrara>,
 'Park51015': <ReportingUnit: Park>,
 'Platte51016': <ReportingUnit: Platte>,
 'Sheridan51017': <ReportingUnit: Sheridan>,
 'Sublette51018': <ReportingUnit: Sublette>,
 'Sweetwater51019': <ReportingUnit: Sweetwater>,
 'Teton51020': <ReportingUnit: Teton>,
 'Uinta51021': <ReportingUnit: Uinta>,
 'Washakie51022': <ReportingUnit: Washakie>,
 'Weston51023': <ReportingUnit: Weston>,
 'Wyoming1': <ReportingUnit: Wyoming (state)>}
palewire commented 12 years ago

This is probably the cause of the issues @onyxfish raised with me in Skype on the other day.

palewire commented 12 years ago

Looks like the candidates have a ton of duplicates now, too. This is a new animal for us to deal with, I fear.

{'100013': <Candidate: None of these candidates>,
 '10048': <Candidate: Mitt Romney>,
 '10088': <Candidate: Barack Obama>,
 '10090': <Candidate: Jill Stein>,
 '10099': <Candidate: Gary Johnson>,
 '10110': <Candidate: Barack Obama>,
 '10186': <Candidate: Mitt Romney>,
 '10187': <Candidate: Gary Johnson>,
 '10188': <Candidate: Jill Stein>,
 '11643': <Candidate: Barack Obama>,
 '11849': <Candidate: Mitt Romney>,
 '11850': <Candidate: Stewart Alexander>,
 '11851': <Candidate: Rocky Anderson>,
 '11852': <Candidate: Roseanne Barr>,
 '11853': <Candidate: Virgil Goode>,
 '11854': <Candidate: James Harris>,
 '11855': <Candidate: Tom Hoefling>,
 '11856': <Candidate: Gary Johnson>,
 '11857': <Candidate: Gloria La Riva>,
 '11858': <Candidate: Merlin Miller>,
 '11859': <Candidate: Jill Reed>,
 '11860': <Candidate: Jill Stein>,
 '11861': <Candidate: Tom Stevens>,
 '11862': <Candidate: Sheila Tittle>,
 '11863': <Candidate: Jerry White>,
 '11883': <Candidate: Barack Obama>,
 '11887': <Candidate: Mitt Romney>,
 '12016': <Candidate: Peta Lindsay>,
 '12017': <Candidate: Jill Stein>,
 '12018': <Candidate: Gary Johnson>,
 '18019': <Candidate: Barack Obama>,
 '18020': <Candidate: Mitt Romney>,
 '18022': <Candidate: Virgil Goode>,
 '18024': <Candidate: Gary Johnson>,
 '18073': <Candidate: Jill Stein>,
 '18074': <Candidate: Rocky Anderson>,
 '18201': <Candidate: Barack Obama>,
 '18202': <Candidate: Mitt Romney>,
 '18205': <Candidate: Gary Johnson>,
 '18206': <Candidate: Jill Stein>,
 '18507': <Candidate: Mitt Romney>,
 '18512': <Candidate: Barack Obama>,
 '18515': <Candidate: Jill Stein>,
 '18518': <Candidate: Gary Johnson>,
 '1918': <Candidate: Barack Obama>,
 '19220': <Candidate: Barack Obama>,
 '19221': <Candidate: Mitt Romney>,
 '19239': <Candidate: Rocky Anderson>,
 '19258': <Candidate: Gary Johnson>,
 '19261': <Candidate: Roseanne Barr>,
 '19262': <Candidate: Thomas Hoefling>,
 '19291': <Candidate: Barack Obama>,
 '19292': <Candidate: Mitt Romney>,
 '19346': <Candidate: Virgil Goode>,
 '19347': <Candidate: Tom Stevens>,
 '19431': <Candidate: Stewart Alexander>,
 '19432': <Candidate: Rocky Anderson>,
 '19433': <Candidate: Andre Barnett>,
 '19434': <Candidate: Roseanne Barr>,
 '19436': <Candidate: Tom Hoefling>,
 '19437': <Candidate: Gary Johnson>,
 '19439': <Candidate: Peta Lindsay>,
 '19441': <Candidate: Jill Stein>,
 '19471': <Candidate: Barack Obama>,
 '19472': <Candidate: Mitt Romney>,
 '19610': <Candidate: Gary Johnson>,
 '20353': <Candidate: Barack Obama>,
 '20493': <Candidate: Mitt Romney>,
 '20736': <Candidate: Gary Johnson>,
 '21615': <Candidate: Barack Obama>,
 '21616': <Candidate: Mitt Romney>,
 '21625': <Candidate: Virgil Goode>,
 '21626': <Candidate: Jill Stein>,
 '21627': <Candidate: Gary Johnson>,
 '21629': <Candidate: James Harris>,
 '21630': <Candidate: Jerry Litzel>,
 '23556': <Candidate: Mitt Romney>,
 '23561': <Candidate: Barack Obama>,
 '23743': <Candidate: James Harris>,
 '23761': <Candidate: Peta Lindsay>,
 '23762': <Candidate: Jack Fellure>,
 '23763': <Candidate: Virgil Goode>,
 '23764': <Candidate: Jerry White>,
 '23765': <Candidate: Jill Stein>,
 '23766': <Candidate: Sheila Tittle>,
 '23811': <Candidate: Rocky Anderson>,
 '23813': <Candidate: Gary Johnson>,
 '25058': <Candidate: Barack Obama>,
 '25059': <Candidate: Mitt Romney>,
 '25102': <Candidate: Jill Stein>,
 '25119': <Candidate: Gary Johnson>,
 '25743': <Candidate: Jerry White>,
 '26136': <Candidate: Barack Obama>,
 '26137': <Candidate: Mitt Romney>,
 '26154': <Candidate: Gloria La Riva>,
 '26155': <Candidate: Gary Johnson>,
 '26156': <Candidate: Virgil Goode>,
 '26281': <Candidate: Jerry White>,
 '26282': <Candidate: Jill Stein>,
 '28154': <Candidate: Barack Obama>,
 '28155': <Candidate: Mitt Romney>,
 '28577': <Candidate: Gary Johnson>,
 '28578': <Candidate: Jill Stein>,
 '28712': <Candidate: Barbara Washer>,
 '29429': <Candidate: Barack Obama>,
 '29430': <Candidate: Mitt Romney>,
 '29431': <Candidate: Gary Johnson>,
 '29436': <Candidate: Jill Stein>,
 '31107': <Candidate: Barack Obama>,
 '31108': <Candidate: Mitt Romney>,
 '31151': <Candidate: Mitt Romney>,
 '31154': <Candidate: Gary Johnson>,
 '31235': <Candidate: Barack Obama>,
 '31261': <Candidate: Barack Obama>,
 '31278': <Candidate: Randall Terry>,
 '31306': <Candidate: Gary Johnson>,
 '31308': <Candidate: Virgil Goode>,
 '31309': <Candidate: Jill Stein>,
 '31318': <Candidate: Barbara Washer>,
 '31708': <Candidate: Gary Johnson>,
 '31868': <Candidate: Mitt Romney>,
 '31875': <Candidate: Jill Stein>,
 '31876': <Candidate: Jim Carlson>,
 '31877': <Candidate: James Harris>,
 '32090': <Candidate: Gary Johnson>,
 '32091': <Candidate: Dean Morstad>,
 '32092': <Candidate: Peta Lindsay>,
 '32093': <Candidate: Virgil Goode>,
 '32094': <Candidate: Rocky Anderson>,
 '32256': <Candidate: Mitt Romney>,
 '32257': <Candidate: Barack Obama>,
 '32261': <Candidate: Jill Stein>,
 '32263': <Candidate: Gary Johnson>,
 '33321': <Candidate: Barack Obama>,
 '33324': <Candidate: Mitt Romney>,
 '33670': <Candidate: Gary Johnson>,
 '34081': <Candidate: Barack Obama>,
 '34082': <Candidate: Mitt Romney>,
 '34090': <Candidate: Jill Stein>,
 '34091': <Candidate: Rocky Anderson>,
 '34092': <Candidate: Virgil Goode>,
 '3486': <Candidate: James Harris>,
 '35603': <Candidate: Barack Obama>,
 '35604': <Candidate: Mitt Romney>,
 '35605': <Candidate: None of these candidates>,
 '35607': <Candidate: Virgil Goode>,
 '35609': <Candidate: Gary Johnson>,
 '37673': <Candidate: Barack Obama>,
 '37680': <Candidate: Mitt Romney>,
 '37820': <Candidate: Rocky Anderson>,
 '37821': <Candidate: Jeff Boss>,
 '37822': <Candidate: Virgil Goode>,
 '37823': <Candidate: Peta Lindsay>,
 '37824': <Candidate: James Harris>,
 '37825': <Candidate: Gary Johnson>,
 '37826': <Candidate: Merlin Miller>,
 '37827': <Candidate: Jill Stein>,
 '37922': <Candidate: Mitt Romney>,
 '37934': <Candidate: Barack Obama>,
 '37937': <Candidate: Gary Johnson>,
 '37949': <Candidate: Rocky Anderson>,
 '37950': <Candidate: Virgil Goode>,
 '37951': <Candidate: Jill Stein>,
 '40111': <Candidate: Barack Obama>,
 '40112': <Candidate: Mitt Romney>,
 '40207': <Candidate: Virgil Goode>,
 '40208': <Candidate: Jill Stein>,
 '40209': <Candidate: Gary Johnson>,
 '41748': <Candidate: Barack Obama>,
 '42397': <Candidate: Mitt Romney>,
 '42656': <Candidate: Gary Johnson>,
 '43773': <Candidate: Rocky Anderson>,
 '43872': <Candidate: Barack Obama>,
 '43982': <Candidate: Will Christensen>,
 '44163': <Candidate: Mitt Romney>,
 '4423': <Candidate: Barack Obama>,
 '4425': <Candidate: Mitt Romney>,
 '44271': <Candidate: Barack Obama>,
 '44272': <Candidate: Mitt Romney>,
 '44285': <Candidate: Gary Johnson>,
 '44464': <Candidate: Virgil Goode>,
 '4475': <Candidate: Mitt Romney>,
 '44780': <Candidate: Barack Obama>,
 '44781': <Candidate: Mitt Romney>,
 '44905': <Candidate: Stewart Alexander>,
 '44906': <Candidate: Richard Duncan>,
 '44907': <Candidate: Virgil Goode>,
 '44908': <Candidate: Gary Johnson>,
 '44909': <Candidate: Jill Stein>,
 '4512': <Candidate: Virgil Goode>,
 '4513': <Candidate: Gary Johnson>,
 '4514': <Candidate: Jill Stein>,
 '45301': <Candidate: Barack Obama>,
 '45302': <Candidate: Mitt Romney>,
 '45347': <Candidate: Jill Stein>,
 '45348': <Candidate: Rocky Anderson>,
 '45349': <Candidate: Virgil Goode>,
 '45350': <Candidate: Peta Lindsay>,
 '45351': <Candidate: Gary Johnson>,
 '4631': <Candidate: Barack Obama>,
 '4645': <Candidate: Gary Johnson>,
 '4650': <Candidate: Rocky Anderson>,
 '4651': <Candidate: Jill Stein>,
 '4652': <Candidate: Will Christensen>,
 '46996': <Candidate: Jack Fellure>,
 '47062': <Candidate: Barack Obama>,
 '47065': <Candidate: Mitt Romney>,
 '4715': <Candidate: Mitt Romney>,
 '47242': <Candidate: Gary Johnson>,
 '47243': <Candidate: Virgil Goode>,
 '47334': <Candidate: Barack Obama>,
 '47335': <Candidate: Mitt Romney>,
 '47487': <Candidate: Virgil Goode>,
 '47488': <Candidate: Gary Johnson>,
 '47489': <Candidate: Jill Stein>,
 '48381': <Candidate: Barack Obama>,
 '4871': <Candidate: Barack Obama>,
 '48745': <Candidate: Mitt Romney>,
 '48807': <Candidate: Virgil Goode>,
 '48808': <Candidate: Gary Johnson>,
 '48809': <Candidate: Jill Stein>,
 '48810': <Candidate: Merlin Miller>,
 '48813': <Candidate: Rocky Anderson>,
 '4917': <Candidate: Gary Johnson>,
 '4918': <Candidate: Randall Terry>,
 '4919': <Candidate: Jill Stein>,
 '49472': <Candidate: Mitt Romney>,
 '49475': <Candidate: Barack Obama>,
 '49860': <Candidate: Gary Johnson>,
 '49902': <Candidate: Jill Stein>,
 '51280': <Candidate: Mitt Romney>,
 '51281': <Candidate: Barack Obama>,
 '51302': <Candidate: Virgil Goode>,
 '51304': <Candidate: Gary Johnson>,
 '51305': <Candidate: Jill Stein>,
 '51917': <Candidate: Barack Obama>,
 '51918': <Candidate: Mitt Romney>,
 '51952': <Candidate: Rocky Anderson>,
 '51953': <Candidate: Peta Lindsay>,
 '51954': <Candidate: Gary Johnson>,
 '54380': <Candidate: Mitt Romney>,
 '54468': <Candidate: Barack Obama>,
 '54469': <Candidate: Mitt Romney>,
 '54471': <Candidate: Virgil Goode>,
 '54472': <Candidate: Gary Johnson>,
 '54549': <Candidate: Barack Obama>,
 '54555': <Candidate: Rocky Anderson>,
 '54556': <Candidate: Virgil Goode>,
 '54557': <Candidate: Gary Johnson>,
 '54558': <Candidate: Gloria La Riva>,
 '54562': <Candidate: Jill Stein>,
 '55621': <Candidate: Barack Obama>,
 '55626': <Candidate: Mitt Romney>,
 '56224': <Candidate: Richard Duncan>,
 '56279': <Candidate: Jill Stein>,
 '56280': <Candidate: Randall Terry>,
 '56281': <Candidate: Gary Johnson>,
 '5659': <Candidate: Barack Obama>,
 '5660': <Candidate: Mitt Romney>,
 '56859': <Candidate: Barack Obama>,
 '5687': <Candidate: Gary Johnson>,
 '5688': <Candidate: Chuck Baldwin>,
 '57931': <Candidate: Mitt Romney>,
 '58163': <Candidate: Gary Johnson>,
 '58164': <Candidate: Jill Stein>,
 '59208': <Candidate: Chuck Baldwin>,
 '59593': <Candidate: Jeff Boss>,
 '59660': <Candidate: Tom Stevens>,
 '6017': <Candidate: Barack Obama>,
 '6018': <Candidate: Mitt Romney>,
 '6028': <Candidate: Gary Johnson>,
 '6142': <Candidate: Jill Stein>,
 '61513': <Candidate: Randall Terry>,
 '61873': <Candidate: Gloria La Riva>,
 '61907': <Candidate: Roseanne Barr>,
 '61912': <Candidate: Stewart Alexander>,
 '62535': <Candidate: Thomas Hoefling>,
 '62536': <Candidate: Merlin Miller>,
 '62537': <Candidate: Sheila Tittle>,
 '62538': <Candidate: Jill Reed>,
 '62562': <Candidate: Peta Lindsay>,
 '62588': <Candidate: Jim Carlson>,
 '62605': <Candidate: Jerry Litzel>,
 '62659': <Candidate: Dean Morstad>,
 '62688': <Candidate: Andre Barnett>,
 '6504': <Candidate: Barack Obama>,
 '6966': <Candidate: Mitt Romney>,
 '7003': <Candidate: Gary Johnson>,
 '7004': <Candidate: Jill Stein>,
 '7005': <Candidate: Rocky Anderson>,
 '7006': <Candidate: James Harris>,
 '7007': <Candidate: Peta Lindsay>,
 '7008': <Candidate: Virgil Goode>,
 '713': <Candidate: Virgil Goode>,
 '74092': <Candidate: Barack Obama>,
 '74093': <Candidate: Mitt Romney>,
 '74238': <Candidate: Mitt Romney>,
 '74239': <Candidate: Barack Obama>,
 '74240': <Candidate: Jill Stein>,
 '74243': <Candidate: Peta Lindsay>,
 '74246': <Candidate: Gary Johnson>,
 '74247': <Candidate: Virgil Goode>,
 '7623': <Candidate: Gloria La Riva>,
 '7987': <Candidate: Barack Obama>,
 '7988': <Candidate: Mitt Romney>,
 '7993': <Candidate: Virgil Goode>,
 '7994': <Candidate: Gary Johnson>,
 '8785': <Candidate: Barack Obama>,
 '8786': <Candidate: Mitt Romney>,
 '8787': <Candidate: Gary Johnson>,
 '893': <Candidate: Mitt Romney>,
 '895': <Candidate: Jill Stein>,
 '9004': <Candidate: Jill Stein>}
palewire commented 12 years ago

The presidential contest is race number "0" in the AP system so I bet we could hinge any special casing on that if we needed to.

schwanksta commented 12 years ago

There's also a difference between the pol_num and the pol_ra_num, which is probably what we key by (so each candidate is a candidate in a different race, eg, presidential race in Alaska vs in Florida).

palewire commented 12 years ago

Okay. I think I know the issue. The recurring race objects in the init directory's race file has us overwriting our race object on initialization, with the Wyoming version being the last to load. Then we only get Wyoming reporting units and then we crash when we get to the results loader. Just a theory, but it's the closest I've been so far. If @onyxfish or @joegermuska or anybody else thinking about this right now is ahead of me, let me know so we don't waste efforts.

onyxfish commented 12 years ago

Ben, just FYI since I couldn't suss out this bug at the time I encountered it, I ended up writing a very simple custom loader to parse the topofticket data. May migrate back to python-elections at some point, but probably not unless we end up needing more features from it. (What we have now is working fine.)

Cheers, C

palewire commented 12 years ago

Sounds good.