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

More vote_total woes #74

Closed eads closed 12 years ago

eads commented 12 years ago

Trying to load Illinois data and running into missing vote_total for certain candidates. The specific error: AttributeError: 'Candidate' object has no attribute 'vote_total'. Is this polluted data, similar to yesterday?

Here are the bad illinois candidates, along with their ap_pol_number's:

schwanksta commented 12 years ago

Well candidates do not in fact have vote_totals, so let's take a look.

schwanksta commented 12 years ago

@eads which pull are you using? get_state?

eads commented 12 years ago

Yup, this is using get_state('IL')

schwanksta commented 12 years ago

So at what point does it fail? The get_state call itself works for me.

eads commented 12 years ago

Here's a boiled down version of this code:

for c in race.candidates:
    vote_count = c.vote_total

Plenty of the candidates do have vote_total's...

eads commented 12 years ago

Also I'm going to lobby to move our repos off unfuddle and onto github sooner rather than later. We're phasing out our current issue tracker, and not having our work on github is a big barrier to collaboration.

schwanksta commented 12 years ago

Thank god, that unfuddle thing is bizarre.

Sorry, it's been a bit since I've been in python-elections in earnest. Why in the shit do we assign vote totals to candidate objects but not define a self.vote_total in the object itself? MYSTERIES.

schwanksta commented 12 years ago

So yeah, I can fix this by adding

    self.vote_total = 0

To the end of the Candidate init method. Makes sense to me. Does that seem like it would fuck with anything, @palewire?

eads commented 12 years ago

Yeah. It's just redmine, but you pay for it and the UI is worse than if you hosted it yourself.

I just wrote the same patch. Seems sane...