Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def demo_InteractiveGrid():
n = 4
adj = np.ones((n,n))
adj = np.triu(adj, 1)
pos = np.random.rand(n,2)
pos[:,0] *= 10
pos[:,1] *= 5
pos = {ii:xy for ii, xy in enumerate(pos)}
fig, ax = plt.subplots()
ax.set(xlim=[0, 10], ylim=[0, 5])
g = InteractiveGrid(adj, pos, ax=ax, node_size=15.)
return g
x, y = self.node_positions[node]
x = np.int(np.round(x))
y = np.int(np.round(y))
self.node_positions[node] = (x, y)
self._update_nodes(nodes)
self._update_edges(nodes)
if self.show_grid:
self._draw_grid()
if self.show_tiles:
self._draw_tiles(color='b', alpha=0.1)
self.fig.canvas.draw_idle()
super(InteractiveGrid, self)._on_release(event)