Skip to content

Commit

Permalink
isort fix
Browse files Browse the repository at this point in the history
  • Loading branch information
thelostone-mc committed Sep 18, 2019
1 parent a463e01 commit 3e068f2
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions app/grants/clr.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def generate_grant_pair(grant):
else:
unique_contributions[profile] = amount

#print(f'Grant Contributions: {grant_contributions}')
#print(f'Unique Contributions: {unique_contributions}')
# print(f'Grant Contributions: {grant_contributions}')
# print(f'Unique Contributions: {unique_contributions}')

profile_pairs = list(combinations(unique_contributions.keys(), 2))
contribution_pairs = list(combinations(unique_contributions.values(), 2))
Expand All @@ -102,12 +102,12 @@ def generate_grant_pair(grant):
'sqrt_of_product_pairs': sqrt_of_product_pairs
}

#print(f'Grant ID: {grant["id"]}')
#print(f'Profile Pairs: {grant["profile_pairs"]}')
#print(f'Contribution Pairs: {grant["contribution_pairs"]}')
#print(f'Sqrt Of Product Pairs: {grant["sqrt_of_product_pairs"]}')
# print(f'Grant ID: {grant["id"]}')
# print(f'Profile Pairs: {grant["profile_pairs"]}')
# print(f'Contribution Pairs: {grant["contribution_pairs"]}')
# print(f'Sqrt Of Product Pairs: {grant["sqrt_of_product_pairs"]}')

#print('=================\n')
# print('=================\n')

return grant

Expand Down Expand Up @@ -167,7 +167,7 @@ def calculate_clr(threshold, grant_contributions):
for grant in grants:
grant_clr = 0
lr_contributions = []
#print(grant['profile_pairs'])
# print(grant['profile_pairs'])
for index, profile_pair in enumerate(grant['profile_pairs']):
pair = str('&'.join(profile_pair))
pair_reversed = str('&'.join(profile_pair[::-1]))
Expand Down Expand Up @@ -219,17 +219,16 @@ def calculate_clr(threshold, grant_contributions):
iterations (int)
'''
def grants_clr_calculate (total_pot, grant_contributions, min_threshold, max_threshold, iterations = 0):
# print("seeing {} contributions".format(len(grant_contributions)))
# print("calculating CLR for contributions:{}".format(grant_contributions))
if len(grant_contributions) == 0:
return 0, 0, 0, 0

iterations += 1
threshold = (max_threshold + min_threshold) / 2
total_clr, grants_clrs = calculate_clr(threshold, grant_contributions)

# print(f'************ POT: {total_pot} | Calculated CLR: {total_clr} | Threshold {threshold} | Iterations {iterations} | GRANT SPLIT {grants_clrs}')
print(f'************ POT: {total_pot} | Calculated CLR: {total_clr} | Threshold {threshold} | Iterations {iterations} | GRANT SPLIT {grants_clrs}')

if iterations == 100:
if iterations > 100 and total_clr <= total_pot:
return grants_clrs, total_clr, threshold, iterations

if total_pot == threshold:
Expand All @@ -240,7 +239,7 @@ def grants_clr_calculate (total_pot, grant_contributions, min_threshold, max_thr
# print(f'++ MIN {min_threshold} NEW MAX {max_threshold}')
elif total_clr < total_pot:
min_threshold = threshold
#print(f'-- NEW MIN {min_threshold} MAX {max_threshold}')
# print(f'-- NEW MIN {min_threshold} MAX {max_threshold}')
else:
return grants_clrs, total_clr, threshold, iterations

Expand Down Expand Up @@ -327,6 +326,3 @@ def predict_clr(random_data=False):
# print("grant: {} potential_clr: {}".format(grant.id, potential_clr))
final_output.append({'grant': grant.id, "clr_prediction_curve": (potential_donations, potential_clr), "grants_clr": grants_clr})
return final_output
# Test 1 iteration
# threshold = 10
# calculate_clr(threshold, grant_contributions)

0 comments on commit 3e068f2

Please sign in to comment.