def make_dmaps(Ns=DEFAULT_NS): dmaps = [] for k in range(len(Ns)): N = Ns[k] counter = Counter(transient=True) psize = int(DEFAULT_PLOT_SIZE / len(Ns)) dmap_update = make_update(k, N, counter) dmap = hv.DynamicMap(dmap_update, streams=[counter]).opts(height=psize, width=psize) # We fetch DEFAULT_N_PER_PI_CALC points each pass through "update", so only count up to N/... dmaps.append(dmap) return dmaps
def make_dmaps(Ns=default_Ns): dmaps = [] for k in range(len(Ns)): N = Ns[k] counter = Counter(transient=True) psize = int(default_plot_size / len(Ns)) dmap_update = make_update(k, N, counter) dmap = hv.DynamicMap(dmap_update, streams=[counter]).opts(height=psize, width=psize) # We fetch default_n_per_pi_calc points each pass through "update", so only count up to N/... dmaps.append(dmap) return dmaps
if x and y: pattern = np.array(shapes[pattern]) r, c = pattern.shape y, x = img.sheet2matrixidx(x, y) img.data[y:y + r, x:x + c] = pattern[::-1] return hv.Image(img) title = 'Game of Life - Tap to place pattern, Doubletap to clear' opts = { 'style': { 'cmap': 'gray', 'toolbar': False, }, 'plot': { 'height': 400, 'width': 800, 'title_format': '{label}', 'xaxis': None, 'yaxis': None } } img = hv.Image(np.zeros((100, 200), dtype=np.uint8)) counter, tap = Counter(transient=True), Tap(transient=True) pattern_dim = hv.Dimension('Pattern', values=sorted(shapes.keys())) dmap = hv.DynamicMap(update, kdims=[pattern_dim], streams=[counter, tap]) doc = renderer.server_doc(dmap.redim.range(z=(0, 1)).opts(**opts)) dmap.periodic(0.05, None) doc.title = 'Game of Life'