Commit 3eaae5fbed37d30bef3532fed5bc369a2734fce9

Authored by Dhruv Kapadia
1 parent 211b3882

Fixing some engine yard pecularities in test rake task

Showing 1 changed file with 2 additions and 2 deletions   Show diff stats
lib/tasks/test_api.rake
... ... @@ -63,10 +63,10 @@ namespace :test_api do
63 63  
64 64 appearances_by_choice_id = wins_hash.merge(losses_hash) do |key, oldval, newval| oldval + newval end
65 65  
66   - sum = total_appearances = appearances_by_choice_id.values.inject(:+)
  66 + sum = total_appearances = appearances_by_choice_id.values.inject(0) {|sum, x| sum +=x}
67 67 mean = average_appearances = total_appearances.to_f / appearances_by_choice_id.size.to_f
68 68  
69   - if sum:
  69 + if sum > 0:
70 70 stddev = Math.sqrt( appearances_by_choice_id.values.inject(0) { |sum, e| sum + (e - mean) ** 2 } / appearances_by_choice_id.size.to_f )
71 71  
72 72 appearances_by_choice_id.each do |choice_id, n_i|
... ...