Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update normalization logic #7008

Merged
merged 1 commit into from
Jun 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions app/grants/clr.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ def get_totals_by_pair(contrib_dict):
boolean
'''
def calculate_clr(aggregated_contributions, pair_totals, verified_list, v_threshold, uv_threshold, total_pot):
saturation_point = False
bigtot = 0
totals = []
for proj, contribz in aggregated_contributions['current'].items():
Expand All @@ -238,17 +237,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 +291,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