def random_coords(class_list):
idx = randint(1, len(class_list))
n = ceil(sqrt(len(class_list)))
m.subdivide(list(range(1, n)), list(range(1, n)))
m, figsize=(n, n), cmap='bone', frame=False, title=st,
subdivisions=True, subdivision_style=dict(color='steelblue'))
def class_id(idx, class_list):
if 0 < idx < len(class_list) + 1:
return str((idx, class_list[idx - 1]))
return str((idx, 'unknown'))
class_list = ["Emily Johnson", "James Smith", "Hannah Brown", "William Davis",
"Olivia Wilson", "Benjamin Taylor", "Ava Martinez",
"Ethan Garcia", "Sophia Rodriguez", "Daniel Hernandez",
"Mia Lee", "Alexander Perez", "Chloe Jackson",
"Samuel Martin", "Isabella Anderson", "Jacob Thompson",
"Charlotte White", "Michael Clark", "Grace Lewis",
"Joseph Wright", "Lily Robinson", "David Baker"]
n, c = ceil(sqrt(len(class_list))), 0
targets = list(range(1, len(class_list) + 1))
arr = np.array(n * [n * [.1]])
mps = [maplot(arr, class_id(0, class_list), n)]
for idx in range(len(class_list) + 1, n ** 2 + 1) :
arr[(idx - 1) // n][(idx - 1) % n] = .3
mps += [maplot(arr, class_id(idx, class_list), n)]
x, y, idx = random_coords(class_list)
mps += [maplot(arr, class_id(idx, class_list), n)]
animate(mps).show(delay=100)
pretty_print(html('%d random (x,y)' % c))
pretty_print(html(class_list[targets[0] - 1]))