code: Debugging Copenhagen
This commit is contained in:
parent
cdead53640
commit
9eedde745d
@ -60,11 +60,13 @@ def main(args):
|
|||||||
# Get all users
|
# Get all users
|
||||||
usrs = np.unique(np.concatenate((cont_data[:, uid_a], cont_data[:, uid_b]), 0))
|
usrs = np.unique(np.concatenate((cont_data[:, uid_a], cont_data[:, uid_b]), 0))
|
||||||
# Check each user
|
# Check each user
|
||||||
goal = [.2, .4, .6, .8, 1]
|
goal = [.2, .4, .6, .8]
|
||||||
# Users suitable for experiments
|
# Users suitable for experiments
|
||||||
usrs_expt = []
|
usrs_expt = []
|
||||||
for usr_i, usr in enumerate(usrs):
|
for usr_i, usr in enumerate(usrs):
|
||||||
|
usr = (14)
|
||||||
print('Checking %d (%d%%: %d/%d)... ' %(usr, (usr_i + 1)*100/len(usrs), usr_i + 1, len(usrs)), end='', flush=True)
|
print('Checking %d (%d%%: %d/%d)... ' %(usr, (usr_i + 1)*100/len(usrs), usr_i + 1, len(usrs)), end='', flush=True)
|
||||||
|
usrs_expt_cur = []
|
||||||
# User's contacts
|
# User's contacts
|
||||||
usr_cont = cont_data[(cont_data[:, uid_a] == usr) | (cont_data[:, uid_b] == usr)]
|
usr_cont = cont_data[(cont_data[:, uid_a] == usr) | (cont_data[:, uid_b] == usr)]
|
||||||
# For each goal
|
# For each goal
|
||||||
@ -79,19 +81,20 @@ def main(args):
|
|||||||
# Check for every possible contact
|
# Check for every possible contact
|
||||||
for u in usrs_cur:
|
for u in usrs_cur:
|
||||||
# Add possible contacts gradually
|
# Add possible contacts gradually
|
||||||
pos_cont.append(u)
|
pos_cont.append(int(u))
|
||||||
# Remove from user contacts
|
# Remove from user contacts
|
||||||
usr_cont_cur = np.copy(usr_cont)
|
usr_cont_cur = np.copy(usr_cont)
|
||||||
for pos_c in pos_cont:
|
for pos_c in pos_cont:
|
||||||
usr_cont_cur = usr_cont_cur[(usr_cont_cur[:, uid_a] != pos_c) & (usr_cont_cur[:, uid_b] != pos_c)]
|
usr_cont_cur = usr_cont_cur[(usr_cont_cur[:, uid_a] != pos_c) & (usr_cont_cur[:, uid_b] != pos_c)]
|
||||||
# Compare the difference
|
# Compare the difference
|
||||||
diff = (len(usr_cont) - len(usr_cont_cur))/len(usr_cont)
|
diff = (len(usr_cont) - len(usr_cont_cur))/len(usr_cont)
|
||||||
# Check if it's close enough to what we need
|
# Check if it is close enough to what we need
|
||||||
if abs(diff - g)/g < .025:
|
if abs(diff - g)/g < .01:
|
||||||
usrs_expt.append([usr, g, pos_cont])
|
usrs_expt_cur.append([int(usr), g, str(pos_cont)])
|
||||||
if g == 1:
|
if g == goal[len(goal) - 1]:
|
||||||
# That's a keeper
|
# That's a keeper
|
||||||
print('[OK]')
|
print('[OK]')
|
||||||
|
usrs_expt += usrs_expt_cur
|
||||||
break
|
break
|
||||||
elif diff > g:
|
elif diff > g:
|
||||||
print('[NOK]')
|
print('[NOK]')
|
||||||
|
Loading…
Reference in New Issue
Block a user