Skip to content

Commit

Permalink
chore: update normalization logic
Browse files Browse the repository at this point in the history
  • Loading branch information
thelostone-mc committed Jun 29, 2020
1 parent ce0e7c4 commit ef069c6
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions app/grants/clr.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,17 +238,12 @@ def calculate_clr(aggregated_contributions, pair_totals, verified_list, v_thresh
bigtot += tot
totals.append({'id': proj, 'clr_amount': tot})

if bigtot >= total_pot:
saturation_point = True
if bigtot >= total_pot: # saturation reached
print(f'saturation reached. Total Pot: ${total_pot} | Total Allocated ${bigtot}. Normalizing')
for t in totals:
t['clr_amount'] = ((t['clr_amount'] / bigtot) * total_pot)

if saturation_point == True:
# find normalization factor
normalization_factor = bigtot / total_pot
# modify totals
for result in totals:
result['clr_amount'] = result['clr_amount'] / normalization_factor

return totals, saturation_point
return totals



Expand Down Expand Up @@ -297,7 +292,7 @@ def run_clr_calcs(grant_contribs_curr, grant_contribs_prev, v_threshold, uv_thre
ptots = get_totals_by_pair(combinedagg)

# clr calcluation
totals, _ = calculate_clr(combinedagg, ptots, vlist, v_threshold, uv_threshold, total_pot)
totals = calculate_clr(combinedagg, ptots, vlist, v_threshold, uv_threshold, total_pot)

return totals

Expand Down

0 comments on commit ef069c6

Please sign in to comment.