## This was all for testing, should be removed once the app is tested # This stuff assigns each letter as a target N_target = np.repeat(Constants.N_stream, 6, axis=0) random.shuffle(N_target) my_count = -1 N_range = list(range(Constants.N,len(N_target))) N_range_tracker = [] for NN in Constants.N_stream: my_count = my_count+1 # choose random trial to have the target temp_idx = random.choice(N_range) # make sure that I don't overwrite any random target indices while (temp_idx in N_range_tracker) or (temp_idx-Constants.N in N_range_tracker): temp_idx = random.choice(N_range) else: N_range_tracker.extend([temp_idx, (temp_idx - Constants.N)]) N_target[[temp_idx, (temp_idx-Constants.N)]] = NN print(NN) # Because the above loop randomly assigns letters wherever no target is indexed, some duplicates may randomly occur. # This loops counts how many duplicates I have and collects their indices in N_targets my_count = -1 one_timer = pd.DataFrame(columns = ['Letter', 'row']) indx_count = -1 for NN in N_target: my_count = my_count + 1 # runs through each row up until end - Nth row if my_count < (len(N_target)-Constants.N): if N_target[my_count] == NN and N_target[my_count+Constants.N] == NN: indx_count = indx_count+1 one_timer.loc[indx_count] = [NN, my_count] # This loop removes all duplicates so that I have exactly one target per letter for NN in Constants.N_stream: tar_idx = one_timer[one_timer['Letter'] == NN]["row"] for ii in range(0, len(tar_idx)-1): idx_to_change = int(one_timer.loc[tar_idx.index[ii], 'row']) while N_target[idx_to_change] == N_target[idx_to_change + Constants.N] or N_target[idx_to_change] == N_target[idx_to_change - Constants.N]: N_target[idx_to_change] = random.choice(Constants.N_stream)