Created
November 17, 2020 18:50
-
-
Save wolterlw/072248a5644f7c445cdc9b39a00fcdb6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def get_thresholded_indices(inp_array, threshold=10, radius=30): | |
y = lambda x: inp_array[x] | |
population = np.random.randint(0,len(inp_array),len(inp_array)) | |
pop_size = len(population)-1 | |
for delta in range(7,0,-1): | |
for i in range(100): | |
population = set([min([max(0,p-delta),p,min(p+delta, pop_size)],key=y) for p in population]) | |
population = sorted(list(population)) | |
for i,j in zip(population[:-1],population[1:]): | |
if abs(j-i) < radius: | |
if i in population and j in population: | |
population.remove(max([i,j],key=y)) | |
for i,j in zip(population[:-1],population[1:]): | |
if abs(j-i) < radius: | |
if i in population and j in population: | |
population.remove(max([i,j],key=y)) | |
population = [x for x in population if y(x) < threshold] | |
return population |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment